



全文预览已结束
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
/*#include#includeusing namespace std;class Pointprivate: float x,y;public: Point() Point(float a,float b):x(a),y(b) Point(Point& a); float Distance(Point b);Point:Point(Point& a) x=a.x; y=a.y;float Point:Distance(Point b) return sqrt(x-b.x)*(x-b.x)+(y-b.y)*(y-b.y); class Line:public Pointprivate: Point a,b;public: Line(float x1,float y1,float x2,float y2):a(x1,y1),b(x2,y2) float Display();float Line:Display() return a.Distance(b);int main() Point a; Point b(7.8,9.8),c(34.5,67.8); a=c; cout两点之间距离是:a.Distance(b)endl; Line s(7.8,8.34,34.5,67.8); couts.Display()endl; return 0;*/#include using namespace std;#include class Point public: double x;double y;Point()Point(double xx,double yy)x = xx;y = yy;Point()double GetX()return x;double GetY()return y;virtual Show() coutthe point is (GetX(),GetY()endl;/圆由点派生class Circle : public Pointdouble Radius;public:Circle()Circle(double Rr)Radius = Rr;Circle()double GetCircleS()return (double)2*3.14*Radius;double GetRadius()return (double)Radius;/线由点派生class Line :public Pointpublic:Point Pa;Point Pb;Line()Line(Point pa,Point pb)Pa = pa;Pb = pb;double GetLineLengh()/获取直线长度double Lx = (Pb.GetX()-Pa.GetX()*(Pb.GetX()-Pa.GetX();double Ly = (Pb.GetY()-Pa.GetY()*(Pb.GetY()-Pa.GetY();return sqrt(Lx+Ly);virtual Show()coutthe length between Pa and Pb is GetLineLengh()endl;/矩形由线派生class Rect:public LinePoint Pc; Point Pd;public:double Lx2;double Ly2;Rect()Rect(Point pc,Point pd)Pc = pc;Pd = pd;double GetLineLengh2(); double GetRectS();double Rect:GetLineLengh2()double Lx2 = (abs(Pa.GetX()-Pc.GetX()*(abs(Pa.GetX()-Pc.GetX();double Ly2 = (abs(Pa.GetY()-Pc.GetY()*(abs(Pa.GetY()-Pc.GetY();return sqrt(double)(Lx2+Ly2);double Rect:GetRectS()return Lx2*Ly2;void main() Point Pa; Point Pb;Line ab(Pa,Pb);coutplease enter point Pa Pa.x ;cinPa.y ;Pa.Show();coutplease enter point Pb Pb.x ;cinPb.y ;Pb.Show();ab.Show();/*void main() Point Pa(1,2);Point Pb(2,3);Point Pc(1,1);Point Pd(3,1);Line obj1(Pa,Pb);Rect obj2(Pa,Pc);Circle cir(2);cout直线1长度为:obj1.GetLineLengh()endl; cout直线2长度为:obj2.GetLineLeng
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 黑河市人民医院电子喉镜检查操作资格认证
- 中国猪去氧胆酸项目创业计划书
- 中国电热靴项目商业计划书
- 邯郸市人民医院声导抗测试规范化操作考核
- 朔州市中医院成本控制能力考核
- 佳木斯市人民医院放疗科住院医师规范化培训考核
- 延边州中医院医学美容科学术交流能力考核
- 张家口市人民医院健康教育技能考核
- 2025年中国水硬性石灰项目投资计划书
- 中国硼酸镁晶须项目商业计划书
- 六年级LOGO小海龟编程
- 非ST段抬高心肌梗塞指南课件
- 驻足思考-瞬间整理思路并有力表达
- 等腰三角形的性质市公开课金奖市赛课一等奖课件
- 生产车间行为规范
- 平面构成教案市公开课金奖市赛课一等奖课件
- Unit 2 Lesson 3 Running and Fitness 课件 高中英语新北师大版必修第一册(2022-2023学年)
- 炸药库建设方案
- 施工现场临时用电安全检查制度(3篇)
- 抗震支吊架计算书、抗震支吊架验收记录表
- 介入性超声基础
评论
0/150
提交评论