首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: 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
45
问题
有如下类定义:
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://kaotiyun.com/show/0Jfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
关于运算符重载,下列表述中正确的是()。
下列字符串中不能作为C++标识符使用的是
下列关于类定义的说法中,正确的是()。
下列字符串中,不可以用作C++标识符的是()。
如果利用C++流进行输入输出,下面的叙述中正确的是()。
建立一个有成员对象的派生类对象时,各构造函数体的执行次序为()。
对长度为n的线性表排序,在最坏情况下,比较次数不是n(n-1)/2的排序方法是( )。
层次型、网状型和关系型数据库划分原则是( )。
在数据库设计中,将E一R图转换成关系数据模型的过程属于()。
随机试题
患者,男性,45岁。被车撞伤4小时,右上腹痛。查体:血压80/60mmHg,脉搏120次/分,右肋见皮擦伤,右上腹压痛明显,全腹轻度肌紧张,移动性浊音阳性,肠鸣音减弱,尿色正常。患者治疗措施应为
右冠状动脉营养部位包括()。
拌和现场进行沥青混合料抽检的目的不是为了检验()。
银行本票可以是即期的,也可以是远期的。()
任何补贴行为,都应该被征收反补贴税。()
《义务教育数学课程标准(2011年版)》指出教学活动是师生积极参与、交往互动、共同发展的过程。教学中应该注意的几个关系是什么?
学制
我国宗教信仰自由政策的实质是:
Neuroscientistshavelongunderstoodthatthebraincanrewireitselfinresponsetoexperience—aphenomenonknownasneuroplast
Duringthetraditionalweddingceremony,thebridalcouplepromiseseachotherlifelongdevotion.Yet,aboutoneoutoffourAme
最新回复
(
0
)