首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: class Father{ //基类 public: Father(string s):name(s) { } private: stri
有如下类定义: class Father{ //基类 public: Father(string s):name(s) { } private: stri
admin
2021-06-10
18
问题
有如下类定义:
class Father{ //基类
public:
Father(string s):name(s) { }
private:
string name;
};
class Mother{ //基类
public:
Mother(string s):name(s) { }
private:
string name;
};
___________________________{ //Father和Mother的派生类
public:
Child(string s1,string s2,string s3):Father(s1),Mother(s2),name(s3) { }
private:
string name;
};
若派生类Child从基类Father和基类Mother处公有继承,则横线处缺失的部分是
选项
A、class Child
B、class Child:Father,Mother
C、class Child:public Father,Mother
D、class Child:public Father,public Mother
答案
B
解析
一个派生类同时继承两个或者多个基类时称为多重继承,其一般形式为:
class 派生类名:[继承方式]基类名1,[继承方式]基类名2,所以D选项正确。
转载请注明原文地址:https://kaotiyun.com/show/Pufp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
使用VC6打开考生文件夹下的源程序文件modi3.cpp,其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。(1)定义类CPlanet的保护数据成员distance和revolvePeriod,它们分别表示行星距太阳的距离和行星的公转周期。其
有如下程序:#include#includeusingnamespacestd;classAnimal{public:virtualstring
if(表达式1)语句1else语句2只有A选项是正确的要定义整型数组x,使之包括初值均为1的三个元素,下列语句正确的是
有如下程序:#includeusingnamespacestd;voidfun(inta,______________){intc;c=a;a=*b;*b=c;}
有如下程序:#includeusingnamespacestd;classObj{staticinti;public:Obj(){i++;}~Obj(){i--;}staticintgetVal(){ret
有如下程序:classBase{public:intdata;};classDerived1:publicBase{};classDerived2:protectedBase{};intmain(){Deriv
有如下程序:#includeusingnamespacestd;intmain(){voidfunction(doubleval);doubleval;function(val);cout
下面类的声明中的几个语句,正确的是(设定语句是主函数中的语句)()。classTestClass{private:intdata;public:TestClass(intg_data
有如下程序:#include<iostream>#include<string>usingnamespacestd;classMyBag{public:MyBag(stringbr,str
请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,该工程中包含一个程序文件main.cpp,其中有坐标点类point、线段类Line和三角形类Triangle的定义,还有main函数的定义。程序中两点间距离的计算是按公式d=实现的,
随机试题
患者,女,20岁。结喉两侧弥漫性肿大,边界不清,皮色如常,无疼痛,诊为气瘿。治疗应首选
如下图所示系统的自由度数是()。
监理工程师对勘察成果的审核与评定是勘察阶段最重要的监理工作,勘察成果应()。
不良贷款是指借款人未能按原定的贷款协议按时偿还()的贷款本息的贷款。
按照并购方的不同身份,可以将并购分为()。
随着人口红利终结,C国奶粉市场将进入残酷的存量竞争新周期,2020年行业洗牌和分化将加剧。国产大品牌在开始强势进攻3~5线市场,以争夺更大市场空间。同时,国产大品牌不愿错过任何增长的可能性,羊奶粉、A2概念和有机奶粉等细分品类新品迭出,让中小品牌难觅差异化
“学而不思则罔,思而不学则殆”的思想出自()。
某县溺水事故频发,对于该县公安机关应当采取的措施,下列哪些说法是正确的?()
土地革命战争时期毛泽东思想开始形成的标志有()
Giventhechoicebetweenspendinganeveningwithfriendsandtakingextratimeforhisschool-work,AndyKliseadmitshewould
最新回复
(
0
)