首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using narnespace std; class test{ private: int a; public: test0{cout+’’con
有如下程序: #include<iostream> using narnespace std; class test{ private: int a; public: test0{cout+’’con
admin
2020-04-07
14
问题
有如下程序:
#include<iostream>
using narnespace std;
class test{
private:
int a;
public:
test0{cout+’’constructor’’+endl;}
test(int a){cout+a+endl;}
test(const test&test)
{
a=test.a;
cout+’’copy constructor’’+en.d1;
}
test(){ cout+’’destructor"+endl;}
};
int main()
{
testA(3);
return 0;
}
运行时输出的结果是( )。
选项
A、3
B、constructor
destructor
C、copy constructor
destructor
D、3
destructor
答案
D
解析
此题考查的是构造函数和析构函数。一个类可以有多个构造函数,但只能有一个析构函数。每一个对象在被创建时,都会隐含调用众多构造函数中的一个,而在销毁时又会隐含调用唯一的析构函数。此题中,主函数创建对象A是会隐含调用。test(int a)这个构造函数,输出3;接着主函数结束,对象A销毁又隐含调用~test()析构函数输出destructor。
转载请注明原文地址:https://kaotiyun.com/show/YR8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
定义如下枚举类型:enumNumber{one=l,tow=2,four=4,eight=8},则下列语句正确的是()。
有如下程序:#include<iostream>usingnamespacestd;classDemopublic:{Demo(){cout<<"defaultconstruct
下列程序中说明的私有成员是______。classLocation{intx;public:voidinit(intinitX,intinitY);private:
按照标识符的要求,开头的符号不能是()。
下面程序的打印结果是【】。#include<iostream>usingnamespacestd;classBase{public:Base(intx){
下列有关内联函数的叙述中,正确的是()。
栈和队列的共同特点是
已知inta,*pa=&a;输出指针pa十进制的地址值的方法是()。
软件详细设计的主要任务是确定每个模块的()。
【】结构,也称为重复结构,即算法中有一组操作要求反复被执行。
随机试题
治疗噤口痢,虚实皆可选用的药物是()(2002年第39题)
Withsuchashorttime(leave)______,it’simpossibleforUStofinishthiscomplicatedexperiment.
腮腺床
对鼠疫耶尔森菌的生长有刺激作用的是()
铝合金窗的型材壁厚不得小于()mm,门的型材壁厚不得小于2mm。
运用土地级差的原理,合理确定()是城市规划经济性的体现。
前苏联莫斯科规划的几个突出规划特点包括()。
结合自己的工作实际,谈谈在今后的工作中如何做到依法执教。
企业发生在建工程减值时,其会计分录:借记“营业外支出”科目,贷记“在建工程减值准备”科目。()
某教师对喜欢打小报告的学生采取故意不理会的方式,这是一种()
最新回复
(
0
)