#include <iostream>
#include <list>
using namespace std;
int main()
{
list<char> listObject;
list<char> revlistObject;
int i;
for(i = 0; i <10; i++)
listObject.push_back('A'+i);
cout << "Size of listObject = " << listObject.size() << endl;
cout << "Original contents: ";
list<char>::iterator p;
while(!listObject.empty()) {
p = listObject.begin();
cout << *p;
listObject.pop_front();
revlistObject.push_front(*p);
}
cout << endl << endl;
cout << "Size of revlistObject = ";
cout << revlistObject.size() << endl;
cout << "Reversed contents: ";
p = revlistObject.begin();
while(p != revlistObject.end()) {
cout << *p;
p++;
}
return 0;
}
|