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

TXT
38
字号
#include<iostream.h>
class location
{
public:
	location(int xx=0,int yy=0)
	{
		X=xx;
		Y=yy;
	}
	location(location & p);
	location()
	{
		cout<<X<<","<<Y<<"Object destroyed."<<endl;
	}
	int getx()
	{return X;}
	int gety()
	{
		return Y;
	}
private:
	int X,Y;
};
location::location(location & p)
{
	X=p.X;
	Y=p.Y;
	cout<<"Copy_constructor called."<<endl;
}
void f(location p)
{
	cout<<"Function :"<<p.getx()<<","<<p.gety()<<endl;
}
main()
{
	location A(1,2);
	f(A);
}

⌨️ 快捷键说明

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