您的位置:首页 > 其它

第4周项目6 point类的完整程序

2016-03-23 21:22 357 查看
问题及代码 :
/*
*Copyright (c) 2016,烟台大学计算机学院
*All rights reserved.
*文件名称 :
*作    者 : 刘云
*完成日期 : 2016年3月12号
*版 本 号 : v1.0
*
*问题描述 :   c++例4-2
*输入描述 :   point类的完整程序
*程序输出 :
*/
#include<iostream>
using namespace std;
class point
{
public :
point(int xx=0,int yy=0)
{
x=xx;
y=yy;
}
point(point &p);
int getx()
{
return x;
}
int gety()
{
return y;
}
private:
int x,y;

};
point::point(point &p)
{
x=p.x;
y=p.y;
cout<<"calling the copy constructer"<<endl;
}
void fun1(point  p)
{
cout<<p.getx()<<endl;
}
point fun2()
{
point a(1,2);
return a;
}
int main()
{
point a(4,5);
point b=a;
cout<<b.getx()<<endl;
fun1(b);
b=fun2();
cout<<b.getx()<<endl;
return 0;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: