首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: class Person{ public: Person(string s):name(s) { } protected: string name;
有如下类定义: class Person{ public: Person(string s):name(s) { } protected: string name;
admin
2015-07-22
35
问题
有如下类定义:
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/BVNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有以下程序:#include<iostream>usingnamespacestd;intmain(){intx=15;while(x>10&&x<50)
下列程序的输出结果是【】#include<iostream>usingnamespacestd;intmain(){intBum=500;int&ref=num;ref+
函数swap(arr,n)可完成对arr数组从第1个元素到第n个元素两两交换。在运行调用函数中的语句后,a[0]和a[1]的值分别为上【】。a[0]=1;a[1]=2;swap(a,2);
下列程序中画线处应填入的语句是classBase{public:voidfun(){cout<<"Baseoffun"<<end1;}};
下列关于构造函数说法不正确的是
在进行了任何C++流的操作后,都可以用C++流的有关成员函数检测流的状态,其中只能用于检测刚进行的操作是否失败函数名是
在面向对象的程序设计中,下列叙述中错误的是
在关系数据库中,用来表示实体之间联系的是
设有下列二叉树:对此二叉树前序遍历的结果为
c++语言标识符是以字母或【】开头的,由字母,数字和下划线组成的字符串。
随机试题
以下体现形式美规律的具体法则不正确的是()。[江西2019]
关于前庭小脑束不正确的是
妊娠期胆囊炎常合并下列哪些疾病:
狼疮性肾炎的活动病理是
我国宪法规定:农村中的下列哪些形式的合作经济,是社会主义劳动群众集体所有制经济?()
压实系数λc为:
下列法律文书中,( )不是人民法院据以执行的根据。
“见贤思齐焉,见不贤而内自省也”所体现的道德修养方法是()。
Economicallydisadvantagedpreschoolchildrenweretrainedinoneofthreetypesoffantasyactivitiesoveraschoolyear.One
Readthetextbelowaboutafter-saleservice.Inmostofthelines41—52thereisoneextraword.Itiseithergrammaticallyinc
最新回复
(
0
)