例:
class A
{
char * data;
...
A(){data = new char[50];}
~A(){delete [] data;}
};
class B
{
A a;
B();
// default destructor
}
void foo()
{
B b;
}
int main()
{
foo();
// "A.data" still in the heap or no?
}
このプログラムは正しく、「A.data」はメインの foo() の後に削除されますか、それともヒープにまだ存在しますか?