資源簡介
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個文件信息
評論
共有 條評論