首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Base{ public: Base(int x=0):valB(x){cout
有如下程序: #include using namespace std; class Base{ public: Base(int x=0):valB(x){cout
admin
2019-05-06
23
问题
有如下程序:
#include
using namespace std;
class Base{
public:
Base(int x=0):valB(x){cout<
~Base(){cout<
private:
int valB;
};
class Derived:public Base{
public:
Derived(int x=0,int y=0):Base(x),valD(y){cout<
~Derived(){cout<
private:
int valD;
};
int main(){
Derived obj12(2,3);
return 0;
}
运行时的输出结果是( )。
选项
A、2332
B、2323
C、3232
D、3223
答案
A
解析
在主函数中创建类Derived对象obj12(2,3)时,因为类Derived是从基类Base派生而来,所以首先调用基类的构造函数,输出2,再调用派生类构造函数,输出3。当主函数运算结果时,首先调用派生类的析构函数,输出3,再调用基类的析构函数输出2。所以输出结果为2332。
转载请注明原文地址:https://kaotiyun.com/show/aKAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#include<iostream>usingnamespacestd;classBase{public:voidoutput(){cout<<l;}virtualvoidPrint
有如下头文件:intf1();staticintf2();classMA{public:intf3();staticintf4();};在所描述的函数中,具有隐含的thi
指针变量所保存的不是一般的数据值,而是程序中另一个对象的______。
数据结构分为逻辑结构和存储结构,循环队列属于______结构。
插入排序算法的主要思想是:每次从未排序序列中取出一个数据,插入已排序序列中的正确位置。Insert类的成员函数sort()实现了插入排序算法,请填空。classInsert{public:Insert(int*b0,intn0)
假定q所指对象的值为25,q+1所指对象的值为46,则执行"(*q)++;"语句后,q所指对象的值为______。
软件生命周期分为软件定义期、软件开发期和软件维护期,详细设计属于______中的一个阶段。
A、 B、 C、 D、 D由主函数main入手,定义了类D对象obj。其中D为类B和C的公有继承,A是C的虚基类。题目中要求的输出结果为“ABCD”,依次为类A,类B,类c.类D中构造函数的输出语句。为了保证
A、 B、 C、 D、 C面向对象中的多态性是指当多种事物继承自一种事物时,同一种操作在它们之间表现出不同的行为:而封装性是指将数据和算法捆绑成一个整体,这个整体就是对象,描述对象的数据被封装在其内部。c++
在学生管理的关系数据库中,存取一个学生信息的数据单位是()。
随机试题
男性20岁,右眼睑红肿、流泪2天,伴大量黄色脓性分泌物,结膜充血水肿明显,角膜透明、前房正常,应进一步检查
患者男,68岁。因右上尖牙残根要求拔除。患者既往患有高血压史10年,糖尿病5年。今测BP120/80mmHg,空腹血糖8.0mmol/L。应为患者选用何种麻醉药物
【背景资料】某公司拟投标某市政工程,该工程技术要求较高,而该公司在这类工程的施工中有丰富的业绩和较高声誉。招标单位提供的招标文件提供了工程量清单。在购买标书后,对报价部分采用了如下计算法,工程量直接使用清单数量,价格使用某定额站的信息价格。由于措施项目
在下列情形中,代理人应当向被代理人承担民事责任的有()。
室内消火栓手轮轮缘上应明显地铸出标示开关方向的箭头和字样,手轮直径应符合要求,如常用的SN65型手轮直径不应小于()mm。
证券价格反映了全部公开的信息,但不反映内幕信息,这样的市场称为()。
()的问世,标志着我国古代建筑技术已经发展到较高的阶段,它是我国和世界建筑史上的珍贵资料。
(2013年真题)根据我国合同法规定,以书面形式作出承诺的,承诺的生效时间是()。
假定在工程文件中有一个标准模块,其中定义了如下记录类型TypeBooksNameAsString*10TelNumAsString*20EndType要求在
硬盘属于
最新回复
(
0
)