首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: class Person{ public: Person(string s):name(s) { } protected: string name;
有如下类定义: class Person{ public: Person(string s):name(s) { } protected: string name;
admin
2019-03-05
25
问题
有如下类定义:
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://jikaoti.com/ti/W9t0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有以下程序#include<iostream>usingnamespacestd:classBase{private:charc;public:Base(charn):c(n){}~Base(){
纯虚函数的声明总是以______结束。
有如下类定义:classTest{public:Test(){a=0;C=0;t//①intf(intA)const{this->a=a;}//②staticintg(){retur
C++语言提供的基本控制结构可以分为3种类型:顺序结构、______和循环结构。
重载的运算符保持其原有的______、优先级和结合性不变。
将E-R图转换到关系模式时,实体与实体间的联系可以表示成()。
Sample是一个类,执行下列语句后,调用Sample类的构造函数的次数是Samplea[2],*P=FlewSample;
下列字符串中可以用作C++标识符的是
在下列枚举符号中,用来表示“相对于当前位置”文件定位方式的是
在下列原型所示的C++函数中,按“传值”方式传递参数的是
随机试题
A.疖B.痈C.丹毒D.急性蜂窝织炎E.淋巴管炎皮肤可见“红线”的是
第一代头孢菌素不具有以下哪个特征
某蓄电池厂男工,工龄10年,主诉头昏、头痛、乏力、记忆减退、睡眠障碍、食欲缺乏、脐周隐痛。经检验尿δ-ALA为28.6μmol/L。首先考虑的诊断是
下列关于个人独资企业的说法,不正确的是:()
自动调节器的基本运算规律包括()。
薪酬水平一般的企业应注意市场薪酬的()
根据以下资料。回答以下小题。按2001-2007年的发展速度,以下判断正确的是()。
表单里有一个选项按钮组,包含两个选项按钮Option1和Option2,假设Option2没有设置Click喜件代码,而Optionl以及选项按钮组和表单都设置了Click事件代码,那么当表单运行时,如果用户单击Option2,系统将
Amtrak(美国铁路客运公司)wasexperiencingadownswinginridership(客运量)alongthelinescomprisingitsrailsystem.Ofmajorconcernt
Whatdoesascientistdowhenheorshe"explains"something?Scientificexplanationcomesintwoforms;generalizationandredu
最新回复
(
0
)