我只是想测试一下并遇到一个奇怪的问题......
#include <iostream>
using namespace std;
class C
{
public:
~C()
{
cout<<"bye world!"<<endl;
}
void foo()
{
cout<<"I'm alive"<<endl;
}
};
int main()
{
C* thing = new C;
delete thing; // destructor called
thing->foo(); // it's alive!!!
}
运行此代码我得到以下结果: &#34;再见世界!&#34; &#34;我活着!&#34; 不应该 - &gt; foo()导致异常,因为之前删除了一行?