#include <iostream>
#include <list>
using namespace std;
int main()
{
list<int> listObject; // an empty list
int i;
for(i = 0; i <10; i++)
listObject.push_back(i);
cout << "List printed forwards:\n";
list<int>::iterator p = listObject.begin();
while(p != listObject.end()) {
cout << *p << " ";
p++;
}
cout << "\n";
cout << "List printed backwards:\n";
p = listObject.end();
while(p != listObject.begin()) {
p--;
cout << *p << " ";
}
return 0;
}
|