Untitled
#include <iostream> #include <list> using namespace std; class Element { int ID; public: Element(int id) { cout<<"Created"<< id<<"at "<<this<<endl; ID = id; } ~Element() { cout<<"Destroy"<< ID<<"at "<<this<<endl; } }; int main() { list<Element*> m_List; Element *e0 = new Element(0); Element *e1 = new Element(1); //add to list m_List.push_back(e0); m_List.push_back(e1); //clear list printf("-----Before clear-----\n"); m_List.clear(); printf("-----After clear-----\n"); return 0; }