#include #include #include #include "obj.h" using namespace std; int main() { const int a[] = {20, 30, 40}; const size_t n = sizeof a / sizeof a[0]; list li(a, a + n); obj o1 = 10; li.push_front(o1); obj o2 = 50; li.push_back(o2); for (list::const_iterator it = li.begin(); it != li.end(); ++it) { cout << *it << "\n"; //or (*it).print() or it->print() } for (list::iterator it = li.begin(); it != li.end();) { if (*it == 20) { //if ((*it).operator int() == 20) { it = li.erase(it); //Calls the object's destructor. } else { ++it; } } for (list::const_iterator it = li.begin(); it != li.end(); ++it) { cout << *it << "\n"; } return EXIT_SUCCESS; }