Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- class Hello {
- public:
- Hello(std::string a) : world(a) {}
- void print() {
- std::cout << world << std::endl;
- }
- private:
- std::string world;
- };
- int main() {
- std::vector<Hello *> *hi = new std::vector<Hello *>;
- hi->push_back(new Hello("world"));
- hi->push_back(new Hello("world1"));
- hi->push_back(new Hello("world2"));
- hi->push_back(new Hello("world3"));
- for (auto i: *hi)
- i->print();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement