I have an class (A) which uses a heap memory allocation for one of it's fields. Class A is instantiated and stored as a pointer field in another class (B).
When I'm done with object B, I call delete, which I assume calls the destructor... But does this call the destructor in class A as well?
Edit:
From the answers, I take that (please edit if incorrect):
delete
instance of B calls B::~B();- which calls A::~A();
- and A::~A should explicitly
delete
all heap-allocated member variables of A; - and finally the memory block storing said instance of B is returned to the heap - when new was used, it first allocated a block of memory on heap, then invoked constructors to initialize it, now after all destructors have been invoked to finalize the object the block where the object resided is returned to the heap.