I have a class inside a class, nested class
class A {
public:
int a;
int b;
class B {
int c;
int d;
}
}
In the process, I allocate the class B's object pointer in heap.
B *bobj = new B();
A *a;
auto_ptr<A> A1(new A());
a = A1.release();
Does deleting the a, delete bobj
as well??
delete a;
or should we explicitly delete the sub class pointer as well?
This is in a code not written by me, I had put the logs at all alloc and deallocs and I see that B *bobj = new B()
, for this there is no delete and for A's object ptr there is a delete. And yet there is no memory leak.That is why I got a doubt what happens in this scenario.