1// list::push_back
2#include <iostream>
3#include <list>
4
5int main ()
6{
7 std::list<int> mylist;
8 int myint;
9
10 std::cout << "Please enter some integers (enter 0 to end):\n";
11
12 do {
13 std::cin >> myint;
14 mylist.push_back (myint);
15 } while (myint);
16
17 std::cout << "mylist stores " << mylist.size() << " numbers.\n";
18
19 return 0;
20}
1list<int> myList = list<int>();
2
3//add a 4 to the end of the list
4myList.push_back(4);
5
6//add a 5 to the begining of the list
7myList.push_front(5);