#include<iostream>
using namespace std;
class point{
private:
int x,y;
public:
point(int a,int b);
~point();
};
int main()
{
point *k=new point(12,12);
delete k;
return 0;
}
point::point(int a,int b)
{
x=a;
y=b;
cout<<"construct..."<<endl;
}
point::~point()
{
cout<<"detruct..."<<endl;
}
输出结果:
construct…
detruct…
注销delete k;
#include<iostream>
using namespace std;
class point{
private:
int x,y;
public:
point(int a,int b);
~point();
};
int main()
{
point *k=new point(12,12);
//delete k;
return 0;
}
point::point(int a,int b)
{
x=a;
y=b;
cout<<"construct..."<<endl;
}
point::~point()
{
cout<<"detruct..."<<endl;
}
输出结果:
construct…
注销掉delete后,将不会再调用析构函数。