关键词不能为空

当前您在: 主页 > 高中公式大全 >

重心公式c++计算出圆和圆柱体的表面积和体积

作者:高考题库网
来源:https://www.bjmy2z.cn/gaokao
2020-09-09 09:18
tags:圆柱体积公式

最简单的三维立体图-劝君珍惜少年时


1.编写一个程序计算出圆和圆柱体的表面积和体积。
要求:(1)定义一个点(poin t)类,包含数据成员x,y(坐
标点),以它为基类,派生出一个circle类(圆类),增加数< br>据成员r(半径),再以circle作为直接基类,派生出一个
cylinder(圆柱体)类 ,再增加数据成员h(高)。设计类中数
据成员的访问属性。
(2)定义基类的派生类圆、圆柱都含有求表面积和体积的
成员函数和输出函数。
(3)定义主函数,求圆、圆柱的面积和体积。

#include
class point
{
private:
float x,y;
public:
point()
{
x=0;
y=0;
}
point(float x1,float y1)
{
x=x1;
y=y1;
}
};
class circle:public point
{

public:
circle(float x2,float y2,float r1):point(x2,y2)
{
r=r1;
}
void ci_area()
{
area1=r*r*3.14;
}
void ci_output()
{
cout<<圆面积=
}
float r;
double area1;
};
class cylinder:public circle
{
private:
float h;
double area2,vo;
public:
cylinder(float x3,float y3,float r2,float h1):circle(x3,y3,r2)
{
h=h1;
}
void cy_area()
{
area2=(2*3.14*r*h+2*3.14*r*r);
}
void cy_volume()
{
vo=3.14*r*r*h;
}
void cy_outout()
{
cout<<圆柱表面积=圆柱体积=
}
};
void main()
{
circle c1(1.0,1.0,2.0);
_area();
_output();
cylinder c2(1.0,1.0,2.0,4.0);
_area();
_volume();
_outout();
}

甘肃省招生网-海洋生物有哪些


室内装潢学校-清明古诗


皖南医学院是几本-太真


化学方程式的配平-元日指的是哪一天


青岛高校-内蒙古自治区省会是哪个城市


高考各科分数-山东省医学专科学校


高考励志图片-中国地理知识点总结


兼词-西安医学高等专科学校



本文更新与2020-09-09 09:18,由作者提供,不代表本网站立场,转载请注明出处:https://www.bjmy2z.cn/gaokao/390423.html

c++计算出圆和圆柱体的表面积和体积的相关文章