首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: 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
73
问题
有如下类定义:
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全国计算机二级
相关试题推荐
下列关于运算符重载的叙述中,错误的是
有如下程序段:inti=1;while(1){i++;if(i==100)break;if(i%2==0)cout
有如下程序:#includeusingnamespacestd;classSample{friendlongfun(Samples);public:Sample(longa){x=a;}private:long
有如下类定义:classMyClass{public:_____________private:intdata;};若要为MyCla
已知Bag是一个类,并有函数FBag定义如下:VoidFBag(){Bag*ptr,my,colleage[2],&sister=my;}则在调用函数FBag()后,Bag类的析构函数被调用
在一个有参函数的原型声明中可有可无的语法成分是
在软件开发中,需求分析阶段可以使用的工具是( )。
有三个关系R、S和T如下:则由关系R和S得到关系T的操作是( )。
下列不属于软件工程3个要素的是()。
存在定义inta[10],x,•pa;,若pa=&a[0],下列的哪个选项和其他3个选项不是等价的?()
随机试题
下列词中全都是一个语素直接构词的是()
被后世称为“诗圣”的唐代大诗人是________。
自律细胞自动兴奋频率的高低主要取决于
男性,59岁。3天前早晨睡眠醒来出现眩晕、呕吐,饮水呛咳,频繁呃逆,右眼裂缩小,右侧面部及左侧上下肢、躯干痛觉减退,走路不稳,同时睡眠增多。为明确诊断。首选的检查是
下列哪一项不属于阿托品的不良反应
D点高程Hm=43.251m,测得后视读数a=1.000m,前视读数b=2.283m。测视线高H1和待求点N的高程分别为()。
可以回购本公司股票的情形不包括()。
申先生,39岁,北京某小区的居民。家中有五口人,父母年近70岁,妻子学历低,下岗在家,靠晚上在街上摆地摊来补贴家用,儿子正在读高中。一家人居住在30多平方米的旧楼房里。申先生工资很低,家庭收入还要靠父母的退休金和低保来维持。最近,申先生和妻子都愁眉不展,因
Thecohesiveness(内聚力)ofafamilyseemstorelyonmemberssharingcertainroutinepracticesandevents.Foragrowingshareoft
Itisclearthatwearerapidlybecomingaglobalculture.Newformsofinformationtechnology,intercontinentaltravel,andthe
最新回复
(
0
)