4-3-2
2013-11-02 15:04
316 查看
#include <iostream> using namespace std; class Point { public: Point(int xx=0,int yy=0) { x=xx; y=yy; cout<<"Constructor is called"<<endl; } Point(Point &p); int getX() { return x; } int getY() { return y; } private://number(编号)、sex(性别)、birthday(出生日期)、id(身份证号) int x,y; }; Point::Point(Point &p) { x=p.x; y=p.y; cout<<"Calling the copy constructor"<<endl; } void f(Point p) { cout<<p.getX()<<endl; } Point g() { Point a(1,2); return a; } int main() { cout<<"Point a(1,2);"<<endl; Point a(1,2); cout<<"Point b(a);"<<endl; Point b(a); cout<<"Point c=a;"<<endl; Point c=a; cout<<"f(a);"<<endl; f(a); cout<<"c=g();"<<endl; c=g(); return 0; }
相关文章推荐
- 为什么数组从0开始
- VC 获取鼠标当前位置坐标和RGB
- Xcode无法启动模拟器或者真机
- UVa 541 - Error Correction
- UML drawing tools
- JDBC批量插入、批量删除、批量更新
- Hadoop RPC概述
- UVA 706 - LCD Display(液晶显示器)
- OAF FlexField中数据库与页面的前后台数据类型转换
- Morning Walk UVA 10596
- 事件驱动I/O模型
- Oracle 存储过程 无法编译 解决方法
- Leetcode: Linked List Cycle II
- 分治法求最大子序列
- IOS UIColor 自定义颜色
- MINI2440+UDA1341TS分析之三
- virtual box上面安装centos
- 初识合成孔径雷达SAR
- SSH整合包详解.Struts2.2.3+Spring3.1.0.M2+Hibernate3.6.6
- 对于org.apache.commons.dbcp.BasicDataSource的配置认知