欢迎来到天天文库
浏览记录
ID:15399395
大小:32.50 KB
页数:4页
时间:2018-08-03
《c++中点线圆的类定义及继承》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、/*#include#includeusingnamespacestd;classPoint{private:floatx,y;public:Point(){}Point(floata,floatb):x(a),y(b){}Point(Point&a);floatDistance(Pointb);};Point::Point(Point&a){x=a.x;y=a.y;}floatPoint::Distance(Pointb){returnsqrt((x-b.x)*(x-b.x)+(y-b.
2、y)*(y-b.y));}classLine:publicPoint{private:Pointa,b;public:Line(floatx1,floaty1,floatx2,floaty2):a(x1,y1),b(x2,y2){}floatDisplay();};floatLine::Display(){returna.Distance(b);}intmain(){Pointa;Pointb(7.8,9.8),c(34.5,67.8);a=c;cout<<"两点之间距离是:"<3、ines(7.8,8.34,34.5,67.8);cout<usingnamespacestd;#includeclassPoint{public:doublex;doubley;Point(){}Point(doublexx,doubleyy){x=xx;y=yy;}~Point(){}doubleGetX(){returnx;}doubleGetY(){returny;}virtualShow(){cout<<4、"thepointis("<5、int{public:PointPa;PointPb;Line(){}Line(Pointpa,Pointpb){Pa=pa;Pb=pb;};doubleGetLineLengh()//获取直线长度{doubleLx=(Pb.GetX()-Pa.GetX())*(Pb.GetX()-Pa.GetX());doubleLy=(Pb.GetY()-Pa.GetY())*(Pb.GetY()-Pa.GetY());returnsqrt(Lx+Ly);}virtualShow(){cout<<"thelengthbetweenPa6、andPbis"<7、GetX()-Pc.GetX()));doubleLy2=(abs(Pa.GetY()-Pc.GetY()))*(abs(Pa.GetY()-Pc.GetY()));returnsqrt((double)(Lx2+Ly2));}doubleRect::GetRectS(){returnLx2*Ly2;}voidmain(){PointPa;PointPb;Lineab(Pa,Pb);cout<<"pleaseenterpointPa"<>Pa.x;cin>>Pa.y;Pa.Show();cout<<"p8、leaseenterpointPb"<>Pb.x;cin>>Pb.y;Pb.Show();ab.Show();}/*voidmain(){PointPa(1,2);PointPb(2,3);PointPc(1,1);PointPd(3,1);Lineobj1(Pa,Pb);Recto
3、ines(7.8,8.34,34.5,67.8);cout<usingnamespacestd;#includeclassPoint{public:doublex;doubley;Point(){}Point(doublexx,doubleyy){x=xx;y=yy;}~Point(){}doubleGetX(){returnx;}doubleGetY(){returny;}virtualShow(){cout<<
4、"thepointis("<5、int{public:PointPa;PointPb;Line(){}Line(Pointpa,Pointpb){Pa=pa;Pb=pb;};doubleGetLineLengh()//获取直线长度{doubleLx=(Pb.GetX()-Pa.GetX())*(Pb.GetX()-Pa.GetX());doubleLy=(Pb.GetY()-Pa.GetY())*(Pb.GetY()-Pa.GetY());returnsqrt(Lx+Ly);}virtualShow(){cout<<"thelengthbetweenPa6、andPbis"<7、GetX()-Pc.GetX()));doubleLy2=(abs(Pa.GetY()-Pc.GetY()))*(abs(Pa.GetY()-Pc.GetY()));returnsqrt((double)(Lx2+Ly2));}doubleRect::GetRectS(){returnLx2*Ly2;}voidmain(){PointPa;PointPb;Lineab(Pa,Pb);cout<<"pleaseenterpointPa"<>Pa.x;cin>>Pa.y;Pa.Show();cout<<"p8、leaseenterpointPb"<>Pb.x;cin>>Pb.y;Pb.Show();ab.Show();}/*voidmain(){PointPa(1,2);PointPb(2,3);PointPc(1,1);PointPd(3,1);Lineobj1(Pa,Pb);Recto
5、int{public:PointPa;PointPb;Line(){}Line(Pointpa,Pointpb){Pa=pa;Pb=pb;};doubleGetLineLengh()//获取直线长度{doubleLx=(Pb.GetX()-Pa.GetX())*(Pb.GetX()-Pa.GetX());doubleLy=(Pb.GetY()-Pa.GetY())*(Pb.GetY()-Pa.GetY());returnsqrt(Lx+Ly);}virtualShow(){cout<<"thelengthbetweenPa
6、andPbis"<7、GetX()-Pc.GetX()));doubleLy2=(abs(Pa.GetY()-Pc.GetY()))*(abs(Pa.GetY()-Pc.GetY()));returnsqrt((double)(Lx2+Ly2));}doubleRect::GetRectS(){returnLx2*Ly2;}voidmain(){PointPa;PointPb;Lineab(Pa,Pb);cout<<"pleaseenterpointPa"<>Pa.x;cin>>Pa.y;Pa.Show();cout<<"p8、leaseenterpointPb"<>Pb.x;cin>>Pb.y;Pb.Show();ab.Show();}/*voidmain(){PointPa(1,2);PointPb(2,3);PointPc(1,1);PointPd(3,1);Lineobj1(Pa,Pb);Recto
7、GetX()-Pc.GetX()));doubleLy2=(abs(Pa.GetY()-Pc.GetY()))*(abs(Pa.GetY()-Pc.GetY()));returnsqrt((double)(Lx2+Ly2));}doubleRect::GetRectS(){returnLx2*Ly2;}voidmain(){PointPa;PointPb;Lineab(Pa,Pb);cout<<"pleaseenterpointPa"<>Pa.x;cin>>Pa.y;Pa.Show();cout<<"p
8、leaseenterpointPb"<>Pb.x;cin>>Pb.y;Pb.Show();ab.Show();}/*voidmain(){PointPa(1,2);PointPb(2,3);PointPc(1,1);PointPd(3,1);Lineobj1(Pa,Pb);Recto
此文档下载收益归作者所有