I have a C++ class, MyClass
. It contains a constructor, destructor and an int pointer private: int *MyPtr;
.
Somewhere, I allocate dynamically a MyClass
Object:
MyClass *my = new MyClass(); //...
Then I call delete my;
Should MyClass
have a destructor which uses something like delete MyPtr
? Or is that MyPtr destroyed when I call delete my
?