If you have a usual pointer (A*
) then the destructor will not be called (and memory for A
instance will not be freed either) unless you do delete
explicitly in B
's destructor. If you want automatic destruction look at smart pointers like auto_ptr
.