#include <list>
#include <cstdio>
using namespace std;
class Potwor
{
public:
virtual void PrzedstawSie() = 0;
};
class Zdzichu : public Potwor
{
public:
virtual void PrzedstawSie() { printf("Jestem Zdzichu!\n"); }
};
class Czesio : public Potwor
{
public:
virtual void PrzedstawSie() { printf("Jestem Czesio!\n"); }
};
class Batman : public Potwor
{
public:
virtual void PrzedstawSie() { printf("Jestem rozowy Batman!\n"); }
};
int main(void)
{
list<Potwor*> potwory;
potwory.push_back(new Zdzichu());
potwory.push_back(new Czesio());
potwory.push_back(new Batman());
for (list<Potwor*>::iterator it = potwory.begin(); it != potwory.end(); ++it)
{
(*it)->PrzedstawSie();
delete *it;
}
return 0;
}
I2luY2x1ZGUgPGxpc3Q+CiNpbmNsdWRlIDxjc3RkaW8+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKY2xhc3MgUG90d29yCnsKcHVibGljOgogIHZpcnR1YWwgdm9pZCBQcnplZHN0YXdTaWUoKSA9IDA7Cn07CgpjbGFzcyBaZHppY2h1IDogcHVibGljIFBvdHdvcgp7CnB1YmxpYzoKICB2aXJ0dWFsIHZvaWQgUHJ6ZWRzdGF3U2llKCkgeyBwcmludGYoIkplc3RlbSBaZHppY2h1IVxuIik7IH0KfTsKCmNsYXNzIEN6ZXNpbyA6IHB1YmxpYyBQb3R3b3IKewpwdWJsaWM6CiAgdmlydHVhbCB2b2lkIFByemVkc3Rhd1NpZSgpIHsgcHJpbnRmKCJKZXN0ZW0gQ3plc2lvIVxuIik7IH0KfTsKCmNsYXNzIEJhdG1hbiA6IHB1YmxpYyBQb3R3b3IKewpwdWJsaWM6CiAgdmlydHVhbCB2b2lkIFByemVkc3Rhd1NpZSgpIHsgcHJpbnRmKCJKZXN0ZW0gcm96b3d5IEJhdG1hbiFcbiIpOyB9Cn07CgppbnQgbWFpbih2b2lkKQp7CglsaXN0PFBvdHdvcio+IHBvdHdvcnk7Cglwb3R3b3J5LnB1c2hfYmFjayhuZXcgWmR6aWNodSgpKTsKCXBvdHdvcnkucHVzaF9iYWNrKG5ldyBDemVzaW8oKSk7Cglwb3R3b3J5LnB1c2hfYmFjayhuZXcgQmF0bWFuKCkpOwoJZm9yIChsaXN0PFBvdHdvcio+OjppdGVyYXRvciBpdCA9IHBvdHdvcnkuYmVnaW4oKTsgaXQgIT0gcG90d29yeS5lbmQoKTsgKytpdCkKCXsKCSAgKCppdCktPlByemVkc3Rhd1NpZSgpOwoJICBkZWxldGUgKml0OwoJfQoJcmV0dXJuIDA7Cn0K