首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下类定义: 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
17
问题
有如下类定义:
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.h>template<classTT>classFF{TTa1,a2,a3;public:FF(TTb1,TTb2,TTb3){
数据管理技术发展过程经过人工管理、文件系统和数据库系统三个阶段,其中数据独立性最高的阶段是【 】。
下面程序的运行结果是【】。#include<iostream>usingnamespacestd;voidfun(int&a,intb=3){staticinti=2;
下面程序的输出结果是【】。#include<iostream>usingnamespacestd;classbase{protected:inta;public:bas
下列程序的运行结果为#include<iostream.h>inti=0;classA{public:A(){i++;}};voidmain(){Aa,
有以下结构体说明和变量的定义,且指针p指向变量a,指针q指向变量b。则不能把结点b连接到结点a之后的语句是structnode{chardata;structnode*next;}
如果类中的一个成员函数的定义实现在类内,则该函数系统自动默认为该类的【】函数。
有如下程序:#include<iostream>usingnamespacestd;classpoint{intx,y;public:point(intvx,intvy)
下列关于this指针的叙述中,正确的是
随机试题
以下哪项对全冠龈边缘位置设计无影响
A.芍药苷B.挥发油以桂皮醛为主C.挥发油以α、β-桉油醇为主,为94%~98%D.桃叶珊瑚苷E.含生物碱,以小檗碱为主牡丹皮的重要化学成分是()
关于导出单位的一些说法,下列说法正确的是____________。
关于桥梁锚具静载锚固性能试验,请回答下列问题。下列关于锚具静载锚固性能试验加载过程的描述,正确的是()。
某可比实例的实物状况比估价对象优9%,则其实物状况修正系数为()。
年度、半年度财务会计报告应当包括()。
根据以下资料。回答以下题。从1981年到2005年,A省生产总值年均增长率最高的是()
央视《全球资讯榜》栏目有段广告:每天,我们只给你介绍三位全球热门人物;只报道最受关注的个球要闻事件;只评选出全球五大上榜公司;只发布全球最新的财经新闻;只介绍最具有想象力的前沿科技——《个球资汛榜》,中央电视俞经济频道,每天中午12:00。知讯者生存。
当建筑物内发生火灾时,人在逃生过程中,不应该:
一台Catalyst6500的3/1端口和一台Catalyst3500的g0/1端口工作在VLANtrunk模式,且端口3/1使用IEEE802.1Q协议,要求传输VLAN1、2和17—37的VLAN信息,不允许传输VLAN3—16的信息,下列
最新回复
(
0
)