class Element {
protected:
Element(int size){}
virtual ~Element(void){}
};
class Square: public Element {
public:
Square(int size):Element(size){}
};
int main()
{
int size = 10;
int index = 0;
//constructor
Element** elements = new Element *[size];
for (int i = 0; i < size; i++) {
elements[i] = 0;
}
//later
elements[index] = new Square(5);
//destructor
delete [] elements;
}
Y2xhc3MgRWxlbWVudCB7CnByb3RlY3RlZDoKICAgIEVsZW1lbnQoaW50IHNpemUpe30KICAgIHZpcnR1YWwgfkVsZW1lbnQodm9pZCl7fQp9OwoKY2xhc3MgU3F1YXJlOiBwdWJsaWMgRWxlbWVudCB7CnB1YmxpYzoKICAgIFNxdWFyZShpbnQgc2l6ZSk6RWxlbWVudChzaXplKXt9Cn07CgppbnQgbWFpbigpCnsKCWludCBzaXplID0gMTA7CglpbnQgaW5kZXggPSAwOwoJCgkvL2NvbnN0cnVjdG9yCglFbGVtZW50KiogZWxlbWVudHMgPSBuZXcgRWxlbWVudCAqW3NpemVdOwoJZm9yIChpbnQgaSA9IDA7IGkgPCBzaXplOyBpKyspIHsKCQllbGVtZW50c1tpXSA9IDA7Cgl9CgkvL2xhdGVyCgllbGVtZW50c1tpbmRleF0gPSBuZXcgU3F1YXJlKDUpOwoJLy9kZXN0cnVjdG9yCglkZWxldGUgW10gZWxlbWVudHM7Cn0=