首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: 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
65
问题
有如下类定义:
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/jvAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
如果算符函数调用格式的表达式:x.operator-(operator++(y,0)中的“—”是作为成员函数重载的,“++”是作为友元函数重载的,那么该表达式还可以表示为:()
以下函数实现的功能是voidfun(char*s){char*p,*q,temp;p=s;q=s+strlen(s)-1;while(p<q){temp=*p;*p=*q;
有如下数组声明:intvalue[30];,下标值引用错误的是
数据结构分为逻辑结构与存储结构,循环队列属于______。
已知语句intm=10;则下列引用的表示中正确的是
在深度为6的满二叉树中,叶子结点的个数为
线性表L=(a1,a2,a3,…ai,…an),下列说法正确的是
数据库系统的核心的是()。
Sample是一个类,执行下列语句后,调用Sample类的构造函数的次数是Samplea[2],*P=FlewSample;
补充完整下面的模板定义:template<classType>//Type为类型参数classXtwo{//由两个Type类型的数据成员构成的模板类Typea;Typeb;public:
随机试题
A、ringerB、hangerC、fingerD、singerC选项C画线字母读[ng],其他选项画线字母读[η]。
胃术后,康复指导建议进食
45岁,男性,任部门经理,送来急诊,自述半小时前突然感到气急、胸闷、心悸、头晕出汗,认为生命垂危,要求紧急处理。近一个月来,这种情况发生过三次,发病间歇期一切正常,发病与饮食无明显关系。最大可能的诊断是
某临街商铺,投资者期望的自有资金资本化率为10%,银行可提供6成、5年利率8%、按月等额偿还的抵押贷款,则综合资本化率为()。[2008年考题]
项目管理团队可以处理项目范围变更请求的方法包括________。
五十多年后回顾这段历史,杜老依然______,然而他也没有______土改实施过程中的缺陷,例如消灭富农和侵犯中农,以及投有严格依法保护劳动者财产利益。填入横线部分最恰当的一项是()。
【S1】【S4】
A、 B、 C、 B由“琳达正在看电视。”可知图B与句意相符。关键词为watchingTV。
Thebesttitleforthispassagewouldbe______.WhichofthefollowingsentenceisNOTmentionedinthepassage?
A、Becausehecan’tfindanidealdate.B、Becauseheistoocommonaperson.C、Becausehehasfailedtorealizehisdreams.D、Bec
最新回复
(
0
)