Tag: dynamic-memory-allocation
-
In C++ Inheritance, Derived class destructor not called when pointer object to base class is pointed to array of derived class
17 I have an Animal class with constructor and destructor. Cat have a private Brain* attribute. Upon construction, Cat creates his Brain using new Brain(); Upon destruction, Cat deletes his Brain. I don’t understand why The cat’s and brain’s destructors not called, when my Base class destructor is virtual? #include <iostream> using std::cout ; using…