Add some data by push_front : list push pop « list « C++ Tutorial






#include <list>
#include <iostream>

using namespace std;

typedef list<int> LISTINT;

int main(void)
{
    LISTINT listOne;
    LISTINT listAnother;
    LISTINT::iterator i;

    listOne.push_front (2);
    listOne.push_front (1);
    listOne.push_back (3);
    listAnother.push_front(4);
    listAnother.assign(listOne.begin(), listOne.end());

    for (i = listAnother.begin(); i != listAnother.end(); ++i)
        cout << *i << endl;
    listAnother.assign(4, 1);

}








17.11.list push pop
17.11.1.list: push_back and push_front
17.11.2.list: push_back, front, empty and pop_front
17.11.3.Add some data by push_front
17.11.4.Demonstrating the difference between push_back() and push_front()
17.11.5.list.pop_front(): remove element from front
17.11.6.difference between push_back() and push_front()
17.11.7.list.pop_back(): remove element from back