首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: 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
52
问题
有如下类定义:
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/75Np777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
如下程序声明了一个使用两个通用数据类型的模板类dataClass,其中构造函数用于初始化两个数据成员,成员函数show用于输出两个数据成员的数值。#include<iostream>usingnamespacestd;【
设某循环队列的容量为50,头指针front=5(指向队头元素的前一位置),尾指针rear =29(指向队尾元素),则该循环队列中共有【 】个元素。
有如下程序:#include<iostream>usingnamespacestd;classPet{charname[10];public:Pet(char*name){st
下列叙述中正确的是( )。
补充完整下面的类定义:constdoublePI=3.14;classCircle{//圆形物体的抽象基类protected:doubler;//半径public:Circle(doubleradius=0):r(radius
在E.R图中,图形包括矩形框、菱形框、椭圆框。其中表示实体联系的是【】框。
设有下列二叉树: 对此二叉树前序遍历的结果为
数据管理技术的发展是与计算机技术及其应用的发展联系在一起的,经历了由低级到高级的发展过程。分布式数据库、面向对象数据库等新型数据库是属于()。
以下程序中函数scmp的功能是返回形参指针s1和s2所指字符串中较小字符串的首地址。#include<string>char*scmp(char*s1,char*s2){if(strc
随机试题
骨髓增生程度极度活跃,原始细胞占30%,这些原始细胞的化学染色结果分别是:POX(+),ALP积分5分,PAS部分细胞呈颗粒状阳性,α-NBE(-),据此,下述最可能的选择是
属于拔牙相对禁忌证的是
关于肾转移癌描述不正确的是
发生淤血的组织局部
贯穿结扎法最适用的是
我国民事诉讼法规定的应当回避的情形包括()。
路基防护中,()适用于土质或风化岩石边坡进行防护。
下列关于法律规则的说法错误的有()。
试评析我国教育研究现状及研究方法上存在的问题。
Forthispart,youareallowed30minutestowriteashortessay.Youshouldstartyouressaywithabriefdescriptionofthepi
最新回复
(
0
)