#include <iostream>
using namespace std;
class X
{
public:
int a;
};
int main(void)
{
X *x = new X;
cout<<x<<endl;
delete x;
cout<<x<<endl;
//多次delete 會爆異常
//delete x;
system("pause");
return 0;
}
linux 爆下面的錯誤
double free or corruption
windows直接爆異常
正確的寫法
if (m_this)
{
delete m_this;
m_this = NULL;
}