首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Base1 { public: Base1(int d) { cout
有如下程序: #include using namespace std; class Base1 { public: Base1(int d) { cout
admin
2015-06-27
25
问题
有如下程序:
#include
using namespace std;
class Base1
{
public:
Base1(int d) { cout<
~Base1() { }
};
class Base2
{
public:
Base2(int d) { cout<
~Base2() { }
};
class Derived : public Base1,Base2
{
public:
Derived(int a,int b, int c, int d):Base1(b), Base2(a), b1(d), b2(c) { }
private:
int b1;
int b2;
};
int main()
{
Derived d(1,2,3,4);
return 0;
}
执行这个程序的输出结果是( )。
选项
A、1234
B、2134
C、12
D、21
答案
D
解析
本题考查派生类的构造函数和析构函数,在定义一个派生类的对象时,先调用基类的构造函数,然后再执行派生类的构造函数,对象释放时,先执行派生类的析构函数,再执行基类的析构函数。本题中定义一个派生类对象时,分别调用基类的构造函数,所以分别输出21。
转载请注明原文地址:https://jikaoti.com/ti/ZaE0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
阅读以下程序,写出程序运行后的输出结果是______。#include<iostream.h>voidmain(){chara[]={’H’,’e’,’r’,’1’,‘o’,’\0’};inti,j;
诊断和改正程序中错误的工作通常称为【】。
在下面的类定义中,横线处应填入的内容是______。classFred{public:voidprint(){cout<<data<<end1;}voidsetData(do
用于输出表达式值的标准输出流对象是【】,用于从键盘上为变量输入值的标准输入流对象是【】。
在数据库系统中,把具有以下特征中之______两个特征的数据模型称为网状模型。
在面向对象方法中,类的实例称为【】。
在进行任何C++流的操作后,都可以用C++流的有关成员函数检测流的状态;其中只能用于检测输入流状态的操作函数名称是()。
若有int(*p)[3]:则以下表述中正确的是______。
有关析构函数的说法不正确的是()。
随机试题
设f(x)=则∫-22f(x)dx=_______.
患儿,男,9岁。口腔检查发现上颌左侧区有恒中切牙,恒侧切牙,乳尖牙,第一乳磨牙,第二乳磨牙及第一恒磨牙。其中第一恒磨牙面龋坏,无自发性痛史,要求治疗上颌左侧区牙齿用牙位记录法记录,正确记录为
病理性黄疸,下列错误的是
患者,男,24岁,乐果中毒,处于昏迷状态,须立即进行洗胃。适宜的洗胃液是
某公司年产焦炭120万t。新建工程项目位于某煤矿,项目投资17.6亿元,于2009年7月建成。工程包括2座55孔炭化室、高6m复热式焦炉,还包括原料场、输配煤系统、筛焦系统、干熄焦(备用湿熄焦)、煤气净化及化产回收等配套工程。装煤出焦、干熄焦烟尘采用地面除
关于会计科目与会计账户关系,说法正确的是()。
普通年金终值系数的基础上,期数加l、系数减1所得的结果,数值上等于()。
设求原方程的通解.
[*]
已知:int[]a=newint[100];,在下列给出的数组元素中,非法的是()。
最新回复
(
0
)