首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: 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
68
问题
有如下类定义:
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/jvAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列关于类中成员函数特征的描述中错误的是
关于数据库系统三级模式的说法,下列()是正确的。
在最坏情况下,冒泡排序所需要的比较次数为______。
以下程序的运行结果是()。#include<iostream.h>voidsub(intx,inty,int*z){*Z=y-x;}voidmain(){inta,b,c;sub(10,5,
下列程序的输出结果为:Ohjectid=0Objectid=1请将程序补充完整。#include<iostream>usingnamespaeestd;classPoint{
有如下程序:#include<iostream>usingnamcspacestd;intmain(){voidfunction(doubleval);doubleval;function(v
对长度为n的线性表进行顺序查找,在最坏情况下所需要的比较次数为()。
面向对象的程序设计主要考虑的是提高软件的
在E-R图中,图形包括矩形框、菱形框、椭圆框。其中表示实体联系的是______框。
关于运算符重载,下列表述中正确的是()。
随机试题
在含有少量Mg2+的CaCl2溶液中,加入H2C2O4沉淀剂时,会产生后沉淀现象。()
属于小细胞未分化型肺癌的是
归脾汤的功用是
蒿芩地丹四物汤的组成下列正确的是
患者,男性,58岁。因“渐发性双上肢震颤、活动不利3年”入院。患者3年前开始出现左上肢震颤,呈搓丸样,静止性为主,紧张、情绪激动时较明显,活动不灵活,表现为行动迟缓;2年前上述症状发展至右上肢,曾到当地医院就诊,考虑震颤查因,给予左旋多巴治疗,症状有所好转
血虚证的临床表现不包括
实施可持续发展战略中可以采用的措施有()。
()是商业助学贷款的还款原则。
下列对“人教版《普通高中课程标准实验教科书.语文》”的解说,不正确的一项是()。
“中国既然有贫乏病,那么开发实业就成为唯一的要求;社会主义、共产主义、国家主义、无政府主义等,在中国都是行不通的。”此观点的持有者是()。
最新回复
(
0
)