When you call delete on a pointer to an object on the heap, that object's destructor is called before the memory is released. This gives your class a chance to clean up, just as it does for objects destroyed on the stack. Listing 10.1 illustrates creating and deleting objects on the heap.
SimpleCat Frisky... Constructor called. SimpleCat * pRags = new SimpleCat.. Constructor called. delete pRags... Destructor called. Exiting, watch Frisky go... Destructor called.
18.220.219.33