class object
{
public:
object(){}
~object(){}
};
int main()
{
object *p = NULL;
{
object a;
p = &a;
if(p){
cout << "not NULL\n";
}
else{
cout << "NULL ptr\n";
}
}
if(p){
cout << "not NULL\n";
}
else{
cout << "NULL ptr\n";
}
return 1;
}
result:
not NULL not NULL
I don't know why this result, I think it is "not NULL" and "NULL". When object
's destructor was called, then p
points to what? How does stack memory work?