- 172
- 0
- 约1.01万字
- 约 14页
- 2015-09-13 发布于重庆
- 举报
11《面向对象程序设计》(C)实验指导书2,计算机网络实验指导书,实验室作业指导书,实验指导书,实验指导书格式,检测实验室作业指导书,java实验指导书,plc实验指导书,单片机实验指导书,操作系统实验指导书
实验 1 类和对象
1.1实验目的和要求
(1) 理解类和对象的概念,掌握声明类和定义对象的方法。
(2) 掌握构造函数和析构函数的实现方法。
(3) 初步掌握使用类和对象编制C++程序。
(4) 掌握对象数组、对象指针和string类的使用方法。
(5) 掌握使用对象、对象指针和对象引用作为函数参数的方法。
(6) 掌握类对象作为成员的使用方法。
(7) 掌握静态数据成员和静态成员函数的使用方法。
(8) 理解友元的概念和掌握友元的使用方法。
1.2实验内容和步骤
输入下列程序
//test4-1.cpp
#includeiostream
using namespace std;
class Coordinate
{ public:
Coordinate(int x1,int y1)
{ x=x1;
y=y1;
}
Coordinate(Coordinate p);
~Coordinate()
{ cout”Destructor is calleded\n”;}
int getx()
{return x;}
int gety()
{return y;}
private:
int x,y;
};
Coordinate::Coordinate(Coordinate p)
{ x=p.x;
y=p.y;
cout”copy-initializa
原创力文档

文档评论(0)