资源简介
C语言程序设计(郑莉)源码.rar

代码片段和文件信息
//4_4.cpp
#include
#include
using namespace std;
class Point //Point类声明
{
public:
Point(int xx=0 int yy=0)
{
X=xx;Y=yy;
//cout<<“Point构造函数被调用“< }
Point(Point &p);
int GetX() {return X;}
int GetY() {return Y;}
//~Point() {cout<<“Point析构函数被调用“< private:
int XY;
};
Point::Point(Point &p) //拷贝构造函数的实现
{
X=p.X;
Y=p.Y;
cout<<“Point拷贝构造函数被调用“< }
//类的组合
class Line //Line类的声明
{
public: //外部接口
Line(int x1int y1int x2int y2);
Line (Point xp1 Point xp2);
/*Line (Point xp1 int x2int y2):p1(xp1)p2(x2y2)
{
cout<<“混合参数“< double x=double(p1.GetX()-x2);
double y=double(p1.GetY()-y2);
len=sqrt(x*x+y*y);
}*/
Line (Line &);
double GetLen(){return len;}
// ~Line(){cout<<“Line析构函数被调用“< private: //私有数据成员
Point p1p2; //Point类的对象p1p2
double len;
};
//组合类的构造函数
Line:: Line(int x1int y1int x2int y2)
:p1(x1y1)p2(x2y2)
{
cout<<“Line构造函数被调用int“< double x=double(x1-x2);
double y=double(y1-y2);
len=sqrt(x*x+y*y);
}
Line:: Line (Point xp1 Point xp2)
:p1(xp1)p2(xp2)
{
cout<<“Line构造函数被调用point“< double x=double(p1.GetX()-p2.GetX());
double y=double(p1.GetY()-p2.GetY());
len=sqrt(x*x+y*y);
}
//组合类的拷贝构造函数
Line:: Line (Line &Seg): p1(Seg.p1) p2(Seg.p2)
{
cout<<“Line拷贝构造函数被调用“< len=Seg.len;
}
//主函数
void main()
{
Point myp1(11)myp2(45); //建立Point类的对象
Line line(myp1myp2); //建立Line类的对象
Line line1(1145);
Line line2(line); //利用拷贝构造函数建立一个新对象
cout<<“The length of the line is:“;
cout< cout<<“The length of the line1 is:“;
cout< cout<<“The length of the line2 is:“;
cout< /*Line line3(myp145);
cout<<“The length of the line3 is:“;
cout< }
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1987 2012-04-04 11:41 例题源代码\4_4.cpp
文件 205 2010-03-16 22:45 例题源代码\ch02\++i---i.cpp
文件 183 2010-03-11 18:09 例题源代码\ch02\++i.cpp
文件 134 2003-12-28 20:52 例题源代码\ch02\2_1.cpp
文件 282 2010-03-23 22:06 例题源代码\ch02\2_10.cpp
文件 606 2003-12-31 12:50 例题源代码\ch02\2_11.cpp
文件 355 2003-12-28 21:16 例题源代码\ch02\2_12.cpp
文件 462 2003-12-31 12:51 例题源代码\ch02\2_13.cpp
文件 789 2003-12-31 12:51 例题源代码\ch02\2_14.cpp
文件 366 2010-03-11 14:47 例题源代码\ch02\2_2.cpp
文件 275 2003-12-28 20:54 例题源代码\ch02\2_3.cpp
文件 536 2003-12-28 20:57 例题源代码\ch02\2_4.cpp
文件 209 2003-12-28 21:00 例题源代码\ch02\2_5.cpp
文件 314 2003-12-28 21:01 例题源代码\ch02\2_6.cpp
文件 165 2003-12-28 21:03 例题源代码\ch02\2_7.cpp
文件 277 2003-12-28 21:05 例题源代码\ch02\2_8.cpp
文件 485 2003-12-28 21:07 例题源代码\ch02\2_9.cpp
文件 429 2010-03-15 15:27 例题源代码\ch02\chap2 jiegou li.cpp
文件 212 2010-03-23 21:51 例题源代码\ch02\for do-while.cpp
文件 317 2010-03-11 15:22 例题源代码\ch02\test.cpp
文件 379 2010-03-23 21:37 例题源代码\ch02\while &do while.cpp
文件 195 2010-03-16 22:38 例题源代码\ch02\字符数据与整型数据.cpp
文件 312 2010-03-30 15:06 例题源代码\ch03\3_1.cpp
文件 571 2003-12-28 22:42 例题源代码\ch03\3_10.cpp
文件 268 2003-12-28 22:50 例题源代码\ch03\3_11.cpp
文件 270 2003-12-28 22:50 例题源代码\ch03\3_12.cpp
文件 504 2003-12-28 22:51 例题源代码\ch03\3_13.cpp
文件 326 2003-12-28 22:51 例题源代码\ch03\3_14.cpp
文件 681 2003-12-31 12:49 例题源代码\ch03\3_15.cpp
文件 1030 2003-12-28 22:54 例题源代码\ch03\3_16.cpp
............此处省略330个文件信息
相关资源
- 《Linux程序设计》第四版pdf高清电子版
- C++ Primer mobi
- 使用 IBM Rational Systems Developer 和 Rati
- VC编程助手2010破解版(原名VA_X_10.6.
- Linux操作系统下C语言编程从零开始
- 一个C++实现的源代码行数统计工具
- easySize使用方法和代码
- TLV解析算法
- C++ 从入门到精通明日科技光盘 百度云
- C和C++.rar
- consts.cpp
- 银行管理系统.cpp
- VC++外挂框架.rar
- VisualC++网络高级编程.(人民邮电.陈坚
- C++黑客编程揭秘与防范.pdf
- BombGoldFlower.cpp
- c++万能外挂.txt
- ZhajingHua.cpp
- C++AMP.pdf
- c++程序设计语言英文第三版.pdf
- Visual_assist_X_for_VC6.0破解版.rar
- 《C语言程序设计》谭浩强.pdf
- c++辅助源码.rar
- GBT28169-2011嵌入式软件C语言编码规范
- 用MFC实现的图像处理源代码总集
- zw_MFC编写一个简单的登录对话框(连
- 鸡啄米:VS2010MFC编程入门教程.pdf
- ATM源代码用c++文件读写.zip
- C语言写的文件传输系统
- MFC黑马程序员教程.rar
评论
共有 条评论