O
Olumide
Hello -
I have two classes A and B as follows:
class B{
public:
~B(){ cout << "destroying B" << endl; }
};
class A{
public:
~A(){ cout << "destroying A" << endl; }
B** b;
};
When used in my main function as follows:
int main()
{
A a;
a.b = new B*[4];
for(int i = 0; i < 3; i++)
{
a.b = new B;
}
}
Only the destructor of A is called.
<ramble>
Do I need to wrap B in an intermediate class before it can be
destroyed? I sort of have the idea that destructors are not called
over(?) a pointer
</ramble>
Thanks,
- Olumide
I have two classes A and B as follows:
class B{
public:
~B(){ cout << "destroying B" << endl; }
};
class A{
public:
~A(){ cout << "destroying A" << endl; }
B** b;
};
When used in my main function as follows:
int main()
{
A a;
a.b = new B*[4];
for(int i = 0; i < 3; i++)
{
a.b = new B;
}
}
Only the destructor of A is called.
<ramble>
Do I need to wrap B in an intermediate class before it can be
destroyed? I sort of have the idea that destructors are not called
over(?) a pointer
</ramble>
Thanks,
- Olumide