第六周上机实践项目:复制构造函数
2016-04-07 09:06
477 查看
/* *Copyright (c)2016,烟台大学计算机与控制工程学院 *All rights reserved. *文件名称:aaa.cpp *作 者:赵子琳 *完成日期:2016年4月7日 *版 本 号:v1.0 * *问题描述:复制构造调用函数的三种情况。 */ #include<iostream> using namespace std; class Point//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 constructor"<<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; }
相关文章推荐
- win7的svchost.exe占用内存过高解决办法
- 项目 - 三角形类雏形
- IIS6.0发布网站(二)
- 虚拟机主机网络通信
- MWC气压计定高
- 实例详解机器学习如何解决问题
- 项目1——分数类的雏形
- 让老版本IE支持html5
- C++第三次实验——个人所得税计算器
- 【小镇的技术天梯】lanmp服务器集群搭建(2)nfs文件共享
- C++第一次上机试验报告2
- 连连看
- 连连看
- C# DateTime 日期加1天 减一天 加一月 减一月 等方法
- 无人机精灵4目避障可能采用的是FPGA+MCU
- android蓝牙扫描(scan)设备分析
- 2.2.4 postfix的调试
- 什么是HTTPS
- 进入单用户模式
- 配置本地ip