fork download
  1. #include <list>
  2. #include <cstdio>
  3.  
  4. using namespace std;
  5.  
  6. class Potwor
  7. {
  8. public:
  9. virtual void PrzedstawSie() = 0;
  10. };
  11.  
  12. class Zdzichu : public Potwor
  13. {
  14. public:
  15. virtual void PrzedstawSie() { printf("Jestem Zdzichu!\n"); }
  16. };
  17.  
  18. class Czesio : public Potwor
  19. {
  20. public:
  21. virtual void PrzedstawSie() { printf("Jestem Czesio!\n"); }
  22. };
  23.  
  24. class Batman : public Potwor
  25. {
  26. public:
  27. virtual void PrzedstawSie() { printf("Jestem rozowy Batman!\n"); }
  28. };
  29.  
  30. int main(void)
  31. {
  32. list<Potwor*> potwory;
  33. potwory.push_back(new Zdzichu());
  34. potwory.push_back(new Czesio());
  35. potwory.push_back(new Batman());
  36. for (list<Potwor*>::iterator it = potwory.begin(); it != potwory.end(); ++it)
  37. {
  38. (*it)->PrzedstawSie();
  39. delete *it;
  40. }
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Jestem Zdzichu!
Jestem Czesio!
Jestem rozowy Batman!