为什么我把一个类的析构函数调用了两次,都能正确执行?
代码如下:
#include <iostream.h>
class a
{
public:
a(int _x)
{
x=_x;
}
int getA()
{
return x;
}
~a()
{
cout<<"i am distructor!";
}
private:
int x;
}
main()
{
int x;
a * _a=new a(100);
x=_a->getA();
cout<<"x is :"<<x<<endl;
_a->~a();
_a->~a();
cin>>x;
return 0;
}
想不明白为什么这样,不是析构一次以后就已经没有此对象了吗