源程序:
#include <iostream>
using namespace std;
class Point
{
private:
int x,y;
public:
Point(int=0,int=0);
~Point();
};
Point::Point(int a,int b):x(a),y(b)
{
cout<<"Initializing"<<a<<","<<b<<endl;
}
Point::~Point() //定义析构函数
{
cout<<"Destructor is active"<<endl;
}
void main()
{
Point *ptr=new Point[2];
delete []ptr;
}