首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: class Person{ public: Person(string s):name(s) { } protected: string name;
有如下类定义: class Person{ public: Person(string s):name(s) { } protected: string name;
admin
2020-07-23
46
问题
有如下类定义:
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/1Lyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#include#includeusingnamespacestd;classTV{public:TV(ints=41):size(
有如下类定义:classMyClass{public:MyClass(doubled=0.0):val(d){}______________/
有如下程序:#include#includeusingnamespacestd;classWheel{public:Wheel(strings=
在一个程序文件中有如下语句:externintvar;关于这个语句,下列表述中错误的是
在一个有参函数的原型声明中可有可无的语法成分是
在面向对象方法中,不属于"对象"基本特点的是( )。
下面对软件特点描述错误的是
下面不能作为软件设计工具的是
软件设计中模块划分应遵循的准则是()。
请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,其中有矩阵基类MatrixBase、矩阵类Matrix和单位阵UnitMatrix的定义,还有main函数的定义。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输
随机试题
A.心阳虚证B.脾肾阳虚证C.肾阳虚证D.心肾阳虚证心悸怔忡,形寒肢冷,肢肿尿少,舌质淡暗或青紫,苔白滑,脉沉细者,所属的证候是
A.盐皮质激素B.糖皮质激素C.性激素D.肾上腺素E.促激素肾上腺皮质网状带分泌
疳证的基本病理改变为
朗文与戴某缔结了一个在甲国和中国履行的合同。履约过程中发生争议,朗文向甲国法院起诉戴某并获得胜诉判决。戴某败诉后就同一案件向我国法院提起诉讼。朗文以该案件已经甲国法院判决生效为由对中国法院提出管辖权异议。依据我国法律、司法解释以及我国缔结的相关条约,下列哪
用友报表系统中,只能生成报表数据,不能进行图表分析。()
利率衍生工具包括()。
在旅游者离开本站之前,导游人员不能安排自由活动。()
旅行社对120人的调查显示,喜欢爬山的与不喜欢爬山的人数比为5:3;喜欢游泳的与不喜欢游泳的人数比为7:5;两种活动都喜欢的有43人。对这两种活动都不喜欢的人数是()。
EDUCATE:CHILD
Forthispart,youarerequiredtowriteacompositionofatleast250wordsaccordingtothefollowinginstruction."Somepeop
最新回复
(
0
)