来自「C语言相关程序」· 代码 · 共 31 行

TXT
31
字号
#include<iostream.h>
#include<stdlib.h>
class location
{
public:
	location(int xx,int yy)
	{
		X=xx;
		Y=yy;
		cout<<"Constructor called: "<<X<<","<<Y<<endl;
	};
	location()
	{
		cout<<"Constructor called."<<endl;
	};
	~location()
	{
	cout<<"Destruct called."<<endl;
	};
private:
	int X,Y;
};
void main()
{
	cout<<"Step one:"<<endl;
	location *ptr1=new location;
	delete ptr1;
	cout<<"Step two:"<<endl;
    ptr1=new location(1,2);
	delete ptr1;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?