class Foo{
public:
Foo(){
cout <<"C ";
}
~Foo(){
cout <<"D ";
}
};
void func(){
Foo* p = new Foo;
p = NULL;
}
int main(){
Foo a;
for (int i=0; i<1; i++){
Foo b;
if (true){
Foo c;
}
func();
}
return 0;
}
For this question, the output is C C C D C D D, and if I delete the func() in the main function, the output become C C C D D D, I understand the first 3 C where it come from, but I don't understand the remaining, please explain it, thanks.