Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <list>
- using namespace std;
- class A{
- public:
- A(){
- cout << "Created" << endl;
- }
- ~A(){
- cout << "Deleted" << endl;
- }
- };
- int main(){
- list<A*> lst;
- for(int i = 0; i < 10; i++)
- lst.push_back(new A());
- cout << "List size: " << lst.size() << endl;
- for(std::list<A*>::iterator it = lst.begin(); it != lst.end(); ++it){
- delete *it;
- it = lst.erase(it);
- }
- cout << "List size: " << lst.size() << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement