- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
程序设计10(Programming 10)
程序设计10(Programming 10)
(1) the derivation of geometric shapes follows:
The plane figure has perimeter and area, and the stereo has surface area and volume. According to the description of the above relation, the perimeter and area of the plane figure, the surface area and volume of the plane are calculated.
Solution:
Use the pointer when running polymorphism
#include iostream.h
#include math.h
Const double PI=3.1415926535;
Class Geometric_shape / / geometry
{
Public:
Virtual double perimeter (=0); / / define pure virtual function, find the circumference
Virtual double area (=0); / / define pure virtual functions for the area
Virtual double volume (=0); / / define pure virtual functions for volume
Virtual void (Show) {}; / / virtual function
};
Class Circle: public Geometric_shape / / circle
{
Double radius;
Public:
Circle ({radius) = 0;} / / define the constructor
Circle (double VV) {radius = VV;} / / define the constructor with arguments
Double (perimeter) / /.
{return 2.0*PI*radius;}
Double (area) / area
{return PI*radius*radius;}
Double (volume) / / volume
{return 0;}
Void, Show ()
{cout radius= radiusendl;}
};
Class Rectangle:public Geometric_shape// rectangle
{
Double, width, length;
Public:
(Rectangle) / / define a constructor, set the initial values of length and width
{width=0; length=0;}
Rectangle (double wid, double len) / / define the constructor with arguments
{
Width = wid;
Length= len;
}
Rectangle (Rectangle, RR)
{
Width = rr.width;
Length = rr.length;
}
Double (perimeter) / /.
{return 2.0* (width+length)}
Double (area) / area
{return width*length;}
Double (volume) / / volume
{return 0;}
Void, Show ()
{cout width=, width\t, length=, lengthendl,}
};
Class Triangle:public Geometric_shape / / triangle
{
Double, a, B, c;
Public:
(Triangle) / / define the constructor
{a=0; b=0; c=0;}
Triangle (double V1, double V2, double V3) / / define the constructor with arguments
{a = V1; b = V2; C = V3;}
Double (perimeter) / /.
{return a+b+c;}
Double (area) / area
{
Do
您可能关注的文档
- 电厂先进个人事迹材料(Power station advanced personal deeds materials).doc
- 电厂化学水处理的发展和应用(Development and application of chemical water treatment in power plant).doc
- 电厂发电用煤质量指标及要求(Quality index and requirement of power generation coal for power plant).doc
- 电厂实习感想(Impression of power plant practice).doc
- 电厂年度安全工作总结(Annual safety work summary of power plant).doc
- 电动力学02034(理论)(Electrodynamics 02034 (Theory)).doc
- 电压3(Voltage 3).doc
- 电台讲座1(Radio Lecture 1).doc
- 电台招聘广告(Radio advertising).doc
- 电喷车故障自诊断系统(Fault diagnosis system of EFI vehicle).doc
最近下载
- 景观规划设计(第3版)课件:滨水景观元素设计.pptx VIP
- 《遥感原理与应用》全套教学课件(共8章完整版).pptx
- 摩擦学基础知识-磨损.ppt VIP
- 景观规划设计(第3版)课件:滨水景观文化设计.pptx VIP
- 甘肃省兰州市城关区树人学校2022-2023学年八年级上学期期中物理试卷(含答案).docx VIP
- 2018-2019学年甘肃省兰州市树人中学八年级(上)期中物理试卷.docx VIP
- 2020-2021学年甘肃省兰州市城关区树人中学八年级(上)期中物理试卷(含解析).doc VIP
- 十五五规划(2026-2030年)是国家未来五年发展的战略性蓝图。以下关于十五.docx VIP
- 电工基础试卷a卷及答案.doc VIP
- 甘肃省兰州市第三十五中学2022-2023学年八年级上学期期中物理试卷(含答案).docx VIP
原创力文档


文档评论(0)