#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 << " ";
cout << endl;
listAnother.assign(4, 1);
for (i = listAnother.begin(); i != listAnother.end(); ++i)
cout << *i << " ";
cout << endl;
listAnother.erase(listAnother.begin());
for (i = listAnother.begin(); i != listAnother.end(); ++i)
cout << *i << " ";
cout << endl;
listAnother.erase(listAnother.begin(), listAnother.end());
if (listAnother.empty())
cout << "All gone\n";
}
|