#include #include #include using namespace std; int main() { const int a[] = {30, 20, 30, 10, 20, 10}; const size_t n = sizeof a / sizeof a[0]; list li(a, a + n); for (list::const_iterator it = li.begin(); it != li.end(); ++it) { cout << *it << "\n"; } cout << "\n"; for (list::iterator it = li.begin(); it != li.end();) { if (*it == 20) { it = li.erase(it); //Get rid of one 20. } else { ++it; } } li.remove(30); //Get rid of every 30. for (list::const_iterator it = li.begin(); it != li.end(); ++it) { cout << *it << "\n"; } cout << "\n"; cout << "size == " << li.size() << "\n"; li.clear(); cout << "size == " << li.size() << "\n"; return EXIT_SUCCESS; }