#include <boost/ptr_container/ptr_vector.hpp>
#include <vector>
class Animal
{
public:
virtual Animal* clone() const = 0;
virtual char type() = 0;
};
Animal* new_clone(Animal const& other){
return other.clone();
}
class Cat : public Animal
{
public:
Cat* clone() const{ return new Cat(*this); }
char type() { return 1; }
};
class Zoo
{
public:
boost::ptr_vector<Animal> animals;
};
int main()
{
std::vector<Zoo> allZoos;
Zoo ourCityZoo;
ourCityZoo.animals.push_back(new Cat());
allZoos.push_back(ourCityZoo);
allZoos.clear();
return 0;
}
I2luY2x1ZGUgPGJvb3N0L3B0cl9jb250YWluZXIvcHRyX3ZlY3Rvci5ocHA+CiNpbmNsdWRlIDx2ZWN0b3I+CgpjbGFzcyBBbmltYWwKewpwdWJsaWM6CiAgICB2aXJ0dWFsIEFuaW1hbCogY2xvbmUoKSBjb25zdCA9IDA7CiAgICB2aXJ0dWFsIGNoYXIgdHlwZSgpID0gMDsKfTsKCkFuaW1hbCogbmV3X2Nsb25lKEFuaW1hbCBjb25zdCYgb3RoZXIpewogIHJldHVybiBvdGhlci5jbG9uZSgpOwp9CgpjbGFzcyBDYXQgOiBwdWJsaWMgQW5pbWFsCnsKcHVibGljOgogICAgQ2F0KiBjbG9uZSgpIGNvbnN0eyByZXR1cm4gbmV3IENhdCgqdGhpcyk7IH0KICAgIGNoYXIgdHlwZSgpIHsgcmV0dXJuIDE7IH0KfTsKCmNsYXNzIFpvbwp7CnB1YmxpYzoKICAgIGJvb3N0OjpwdHJfdmVjdG9yPEFuaW1hbD4gYW5pbWFsczsKfTsKCmludCBtYWluKCkKewogICAgc3RkOjp2ZWN0b3I8Wm9vPiBhbGxab29zOwoKICAgIFpvbyBvdXJDaXR5Wm9vOwogICAgb3VyQ2l0eVpvby5hbmltYWxzLnB1c2hfYmFjayhuZXcgQ2F0KCkpOwoKICAgIGFsbFpvb3MucHVzaF9iYWNrKG91ckNpdHlab28pOwogICAgYWxsWm9vcy5jbGVhcigpOwoKICAgIHJldHVybiAwOwp9Cg==