首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: 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
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/1Lyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
已知函数f1调用函数f2,若要把这两个函数的定义放在同一个文件中,则
有三个关系R、S和T如下:则由关系R和S得到关系T的操作是
模板对类型的参数化提供了很好的支持,因此()。
下列符号中,正确的C++标识符是()。
软件设计中模块划分应遵循的准则是( )。
下列关于运算符重载的叙述中,错误的是()。
数据库管理系统是( )。
下面是重载为非成员函数的运算符的函数原型,其中错误的是()。
若磁盘上已存在某个文本文件,其全路径文件名为d:\ncre\test.txt,下列语句中不能打开该文件的是
判断一个字符串是否是回文串的递归函数定义如下:boolhuiwen(strings){intn=s.length();if(n
随机试题
怎么就车检查怠速控制阀?
A、痫病之心肾亏虚证B、痫病之心脾两虚证C、痫病之风痰阻络证D、痫病之瘀阻脑络证患者平素头昏头痛,突发左侧肢体抽搐,颜面口唇青紫,舌暗红,苔薄白,脉弦,属于()证型。
护理气性坏疽病人的对症处理措施是()
某男,30岁,因上颌第三恒磨牙拔除,立即出现患侧面部肿胀,下列哪项处理是错误的
指纹从虎口到食指端,其三关排列次序
施工图预算是在施工图设计完成后,以施工图为依据,根据()进行编制的。
()是指在约定期限内交换约定数量两种货币的本金,同时定期交换两种货币利息的交易。
一个袋子里有6个球,其中有2个蓝色球。任意从袋子里拿2个球,拿到蓝色球的概率有
设a和b均为double型变量,且a=5.5、b=2.5,则表达式(int)a+b/b的值是
Americansuffersfromanoverdoseofwork【C1】______whotheyareorwhattheydo.Theyspend【C2】______timeatworkthanatanyti
最新回复
(
0
)