fork download
  1. class Element {
  2. protected:
  3. Element(int size){}
  4. virtual ~Element(void){}
  5. };
  6.  
  7. class Square: public Element {
  8. public:
  9. Square(int size):Element(size){}
  10. };
  11.  
  12. int main()
  13. {
  14. int size = 10;
  15. int index = 0;
  16.  
  17. //constructor
  18. Element** elements = new Element *[size];
  19. for (int i = 0; i < size; i++) {
  20. elements[i] = 0;
  21. }
  22. //later
  23. elements[index] = new Square(5);
  24. //destructor
  25. delete [] elements;
  26. }
Success #stdin #stdout 0.02s 2852KB
stdin
Standard input is empty
stdout
Standard output is empty