fork download
  1. #include <iostream>
  2. #include <list>
  3.  
  4. class Whine {
  5. public:
  6. Whine() {
  7. std::cout << this << ": Whine constructed." << std::endl;
  8. }
  9.  
  10. ~Whine() {
  11. std::cout << this << ": Whine destroyed." << std::endl;
  12. }
  13. };
  14.  
  15. int main()
  16. {
  17. std::list<Whine *> wl;
  18.  
  19. wl.push_back(new Whine);
  20. wl.push_back(new Whine);
  21. wl.push_back(new Whine);
  22.  
  23. for (std::list<Whine *>::const_iterator it = wl.begin(); it != wl.end(); ++it)
  24. delete *it;
  25.  
  26. wl.clear();
  27. }
Success #stdin #stdout 0.02s 2856KB
stdin
Standard input is empty
stdout
0x8e68008: Whine constructed.
0x8e68028: Whine constructed.
0x8e68048: Whine constructed.
0x8e68008: Whine destroyed.
0x8e68028: Whine destroyed.
0x8e68048: Whine destroyed.