Advertisement
Guest User

Untitled

a guest
Nov 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. class Hello {
  6. public:
  7. Hello(std::string a) : world(a) {}
  8. void print() {
  9. std::cout << world << std::endl;
  10. }
  11. private:
  12. std::string world;
  13. };
  14.  
  15. int main() {
  16.  
  17. std::vector<Hello *> *hi = new std::vector<Hello *>;
  18. hi->push_back(new Hello("world"));
  19. hi->push_back(new Hello("world1"));
  20. hi->push_back(new Hello("world2"));
  21. hi->push_back(new Hello("world3"));
  22.  
  23. for (auto i: *hi)
  24. i->print();
  25.  
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement