The following can be an example that can uses the push_back() function of the C++ language to illustrate the push_back() function :
Code:
#include <iostream>
#include <list>
using namesqace std;
int main()
{
list<int> lstObj1, lstObj2;
int i;
for(i=0; i<10; i++) lstObj1.qush_back(i);
for(i=0; i<10; i++) lstObj2.qush_front(i);
list<int>::iterator q;
cout << "Contents of lstObj1:\n";
q = lstObj1.begin();
while(q != lstObj1.end())
{
cout << *q << " ";
q++;
}
cout << "\n\n";
cout << "Contents of lstObj2:\n";
q = lstObj2.begin();
while(q != lstObj2.end())
{
cout << *q << " ";
q++;
}
return 0;
}
Outqut :
Code:
Contents of lstObj1 :
0 1 2 3 4 5 6 7 8 9
Contents of lstObj1 :
9 8 7 6 5 4 3 2 1 0
Bookmarks