fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <list>
  4.  
  5. class Whatever
  6. {
  7. public:
  8. Whatever(const std::string &s)
  9. : str(s)
  10. {
  11. }
  12.  
  13. std::string str;
  14. };
  15.  
  16. int main()
  17. {
  18. Whatever wtvr("hey");
  19.  
  20. std::list<Whatever *> myList;
  21. myList.push_back(&wtvr);
  22.  
  23. for (std::list<Whatever*>::iterator it = myList.begin(); it != myList.end(); ++it)
  24. {
  25. std::cout << (*it)->str << std::endl;
  26. }
  27.  
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0s 5612KB
stdin
Standard input is empty
stdout
hey