#include <iostream>
#include <list>
using namespace std;
int main()
{
list<int> listObject;
list<int>::iterator p;
int i;
for(i = 0; i < 20; i++)
listObject.push_back(i%3);
cout << "Original list: ";
for(p = listObject.begin(); p != listObject.end(); p++)
cout << *p << " ";
cout << endl;
listObject.remove(1); // remove all 1's
cout << "Modified list: ";
for(p = listObject.begin(); p != listObject.end(); p++)
cout << *p << " ";
cout << endl;
return 0;
}
|