首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: 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
26
问题
有如下类定义:
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全国计算机二级
相关试题推荐
非成员函数应声明为类的【 】函数才能访问这个类的private成员。
下列关于this指针的叙述中,正确的是
有如下函数模板定义: template<class t> T func(Tx,Ty){return x*x+y*y;} 在下列对func的调用中,错误的是
数据结构中,与所使用的计算机无关的是数据的
利用成员函数对双目运算符重载,其左操作数为______,右操作数为______。
类模板的使用实际上是将类模板实例化成一个具体的()。
下面程序的输出结果是【】。#include<iostream>usingnamespacestd;classA{inta,b;public:A(){
设一棵二叉树中有3个叶子结点,有8个度为1的结点,则该二叉树中总的结点数为【】。
下列的各类函数中,()不是类的成员函数。
具有3个结点的二叉树有
随机试题
锥体束损害时不应出现的体征是
各种抗生素在分类上属于
甲与乙、丙成立一合伙企业,并被推举为合伙事务执行人,乙、丙授权甲在3万元以内的开支及30万元内的业务可以自行决定。甲在任职期间内实施的下列行为哪些是法律禁止或无效的行为?
下列选项中,属于风险转移中的非保险转移方式的有()。
因当事人一方的违约行为,侵害对方人身、财产权益的,受侵害方()。
借款人还款能力的主要标志是()
“六三三学制”又称为()学制。
John__________almostallofhisrecordstohisfriends,buthestillhadaveryfewleft.
教学的首要任务是()。
MoneyinAmericaMoneyisusedtobuygoodsorservicesand【1】______debts. 【1】_________InAmerica,moneysupplycon
最新回复
(
0
)