首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: class Person{ public: Person(string s):name(s) { } protected: string name;
有如下类定义: class Person{ public: Person(string s):name(s) { } protected: string name;
admin
2021-05-06
51
问题
有如下类定义:
class Person{
public:
Person(string s):name(s) { }
protected:
string name;
};
class Father:virtual public Person{
public:
Father(string s):Person(s) { }
};
class Mother:virtual public Person{
public:
Mother(string s):Person(s) { }
};
class Child:public Father,public Mother,virtual public Person{
public:
Child(string s1,string s2,string s3):Mother(s1),Father(s2),Person(s3) { }
};
在建立派生类Child的对象时,其基类Father、Mother和Person的构造函数的调用顺序为
选项
A、Father,Mother,Person
B、Mother,Father,Person
C、Person,Father,Mother
D、Father,Person,Mother,Person,Person
答案
C
解析
执行派生类构造函数的顺序是:
1、调用基类构造函数,2、调用子对象构造函数,3、再执行派生类构造函数,所以本题中先调用基类person构造函数,然后执行father构造函数,最后执行mother构造函数。
转载请注明原文地址:https://www.kaotiyun.com/show/0Jfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#includeusingnamespacestd;classPoint{public:Point(intxx=0,intyy=0):x(xx),
下列关于类定义的说法中,正确的是()。
下列关于析构函数的描述中,错误的是()。
下面是类shape的定义:c1assShape{public:VirtualvoidDraw()=0;};下列关于Shape类的描述中,正确的是()。
要定义整型数组x,使之包括初值为0的三个元素,下列语句中错误的是()。
在数据库设计中,将E-R图转换成关系数据模型的过程属于()。
下列关于C++预定义流对象的叙述中,正确的是()。
下面描述中不属于数据库系统特点的是()。
在为一个类重载下列运算符时,只能作为该类成员函数重载的运算符是()。
随机试题
会计人员继续教育的内容不包括()。
新股竞价发行方式的最大缺陷是( )。
根据支付结算法律制度的规定,下列账户种类中,属于单位银行结算账户的有()。
2003年1月1日,甲、乙、丙三个企业合并设立一个新的企业,合并各方解散,合并前甲企业所得税由国家税务局征收,乙、丙企业所得税由地方税务局负责征收,则新企业的所得税仍由地方税务局征收。()
行政管理的编制管理是指按法律规定的制度和程序,为有效控制()所进行的管理。
有一个学生的成绩恰好低于平均成绩一个标准差,他在该班的百分位点是()
MicrosoftfounderBillGateshas______aboutbeingaparent,statingthat13isanappropriateageforachild’sfirstcellphone
LifeSpanAboutacenturyago,theaveragelifespanforAmericanswasabout50years./Today,thetypicalAmericanlivesfo
Theysucceededatlastafteradoptingan(effect)______teachingmethod.
TheFutureIsAnotherCountry[A]AcoupleofmonthsorsoafterbecomingBritain’sprimeminister,DavidCameronwantedafewt
最新回复
(
0
)