Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <vector>
- class IDrawAction
- {
- public:
- IDrawAction() {}
- ~IDrawAction() {}
- virtual void draw() = 0;
- };
- class Drawer : public IDrawAction
- {
- std::vector<IDrawAction *> drawable;
- public:
- Drawer(){}
- ~Drawer() {}
- void draw()
- {
- for (const auto &I : drawable)
- {
- I->draw();
- }
- }
- void addDrawable(IDrawAction *ptr)
- {
- drawable.push_back(ptr);
- }
- };
- class SomeObject : public IDrawAction
- {
- public:
- SomeObject() {}
- ~SomeObject() {}
- void draw()
- {
- printf("wtf\n");
- }
- };
- int main()
- {
- Drawer d;
- SomeObject obj;
- d.addDrawable(&obj);
- d.addDrawable(&obj);
- d.addDrawable(&obj);
- d.addDrawable(&obj);
- d.draw();
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement