首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序中,先声明一个圆类circle和一个桌子类table,另外声明一个圆桌类roundtable,它是由 circle和table两个类派生的,要求声明一个圆桌类对象,并输出圆桌的高度,面积和颜色。请填空完成程序 #include<iostrea
下列程序中,先声明一个圆类circle和一个桌子类table,另外声明一个圆桌类roundtable,它是由 circle和table两个类派生的,要求声明一个圆桌类对象,并输出圆桌的高度,面积和颜色。请填空完成程序 #include<iostrea
admin
2009-01-15
35
问题
下列程序中,先声明一个圆类circle和一个桌子类table,另外声明一个圆桌类roundtable,它是由 circle和table两个类派生的,要求声明一个圆桌类对象,并输出圆桌的高度,面积和颜色。请填空完成程序
#include<iostream.h>
#include<string.h>
class circle{
double radius;
public:
circle(double r){radius=r;}
double get_area(){return 3.416*radius*radius;}
};
class table{
double height;
public:
table(double h)<height=h;}
double get_height(){return height;}
};
class roundtable:public table,public circle{
char *color;
public:
roundtable(double h,double r,char c[]): 【 】 {
color=new char[strlen(c) +1];
【 】;
};
char*get_color(){return color;}
}:
void main(){
roundtable rt(0.8,1.0,“白色”);
cout<<"圆桌的高:"<<rt. get_height()<<end1;
cout<<"圆桌面积:"<<rt.get_area()<<end1;
cout<<"圆桌颜色:"<<n.get color()<<end1;
}
选项
答案
circle(r), table(h) strcpy(color, c)
解析
转载请注明原文地址:https://kaotiyun.com/show/Jgkp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有以下结构体说明、变量定义和赋值语句:struetSTD{charname[10];intage;charsex;}s[5],*ps;ps=&s[0];则下列scartf函数调用语句有错误的是()。
某系统总体结构如下图所示,该系统结构图的深度是
有以下程序#includemain(){charc[2][5]={"6938","8254"},*p[2];inti,j,s=0;for(i=0;i
若有定义语句doublex,y,*px,*py;,执行了px=&x;py=&y;之后,正确的输入语句是()。
有以下结构体说明、变量定义和赋值语句structSTD{charname[10];intage;charsex;}s[5],*ps;ps=&s[0];则以下scanf函数调用语句有错误的是
有两个关系R和S如下:由关系R通过运算得到关系S,则所使用的运算为
下列程序中函数f的功能是:当flag为1时,进行由小到大排序;当flag为0时,进行由大到小排序。voidf(intb[],intn,intflag){inti,j,t;for(i=0;i<n-1;i++)for(j=i+1;j
有三个关系R、S和T如下: 则由关系R和S得到关系T的操作是
设有某函数的说明为int*func(inta[10],intn);则下列叙述中,正确的是
设有如下关系表:则下列操作正确的是()。
随机试题
有关子宫内膜周期性变化哪项正确( )。
下列关于工程量确认的表述中,正确的有()。
统计描述是统计分析的最基本内容,是指应用()等方法,对资料的数量特征及其分布规律进行测定和描述。
采用邀请招标方式选择工程监理单位时,建设单位的正确做法是()。
知识获取的主要途径是直观和()
阅读以下文字,完成以下问题。人何时最容易产生灵感呢?据有关专家调查,是在似睡非睡、似梦非梦中闪现念头时。专家们对298人进行调查后惊奇地发现,大约90%(262人)的人产生灵感的时间几乎在同一时间:“特别容易激发灵感的时间”是早晨起床后、深夜、沉
福禄培尔重视发挥游戏在幼儿教育中的价值,他将游戏看作是()。(2016年)
简述元朝书院的发展过程。
《刑法》第140条规定:“生产者、销售者在产品中掺杂、掺假,以假充真,以次充好或者以不合格产品冒充合格产品,销售金额五万元以上不满二十万元的,处二年以下有期徒刑或者拘役,并处或者单处销售金额百分之五十以上二倍以下罚金;销售金额二十万元以上不满五十万元的,-
设A是n阶非零矩阵,A*是A的伴随矩阵,AT是A的转置矩阵,如果AT=A*,证明任一n维列向量均可由矩阵A的列向量线性表出.
最新回复
(
0
)