考虑以下代码:-
#include <iostream>
class Test
{
public:
int k=10;
};
int main(int argc, const char * argv[])
{
Test *t = new Test();
delete t;
//t1 = NULL;
t->k=50;
printf("\n%d",t->k);
return 0;
}
它的输出是50
虽然t
被删除了。为什么不崩溃?我在 Mac OS x 中使用 Xcode。