首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class test{ private: int a; public: test(){cout<<“constructor”<
有如下程序: #include using namespace std; class test{ private: int a; public: test(){cout<<“constructor”<
admin
2020-12-21
18
问题
有如下程序:
#include
using namespace std;
class test{
private:
int a;
public:
test(){cout<<“constructor”<<endl;}
test(int a){tout<<a<<endl;}
test(const test&_test){
a=_test.a:
cout<<“copy constructor”<<endl;
}
~test()j cout<<“destructor”<<endl;}
};
int main(){
test A(3);
return 0;
}
执行这个程序的输出结果是( )。
选项
A、3
B、constructor
estructor
C、copyconstructor
destructor
D、3
destructor
答案
D
解析
本题考查默认构造函数和带参数的构造函数以及析构函数,本题中定义了一个对象A(3),对象带着参数,所以执行带参数的构造函数,输出3,然后执行析构函数,输出destructor。所以本题答案为D。
转载请注明原文地址:https://kaotiyun.com/show/npyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
使用VC6打开考生文件夹下的源程序文件modil.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为:m=一10n=一10p=0q=—10z=A注意:错误的语句在∥********
使用VC6打开考生文件夹下的源程序文件modil.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为:1063022注意:错误的语句在∥********error********的下面,修
有如下类的定义,横线处的语句是()。classTestClass{________intx,y;public:TestClass(inta=0,intb=0){X=a:
若已定义inta[]={0,1,2,3,4,5,6,7,8,9},*p=a,i;其中0
下列运算符不能重载为友元函数的是()。
下列关于模板的叙述中,错误的是
使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能:(1)完成类MyArrayClass的构造函数,申请数组的大小,请在注释//********1********后
使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能:(1)定义复数类CComplex的私有成员变量real和imaginary,分别用来表示复数的实部和虚部,都是
下面叙述中正确的是
下列说法中错误的是()。
随机试题
下列关于总监理工程师的论述不正确的是()。
Bythetimehewas1yearsold,hehaddevelopedtotheextentthatheneverlistenedtohisparents’advice.
设函数z=x2ey,则全微分dz=__________。
Wedon’tdoubt______hecandoagoodjob,concerninghisexperience.
男性,38岁,5年前发现HBsAg(+),近2年来数次出现ALT增高,经治疗后恢复,近2个月来出现乏力、纳差。体检:巩膜不黄,亦未见肝掌、蜘蛛痣,肝肋下1cm,脾侧位可及。ALT4201U/L,TBil20μmol/L,HBsAg(+)。是否应进行抗病
患者,张某,70岁,在输液过程中,突然出现呼吸困难、胸闷、咳嗽、咳粉红色泡沫样痰,严重时痰液从口鼻涌出,两肺可闻及湿哕音,心率快且节律不齐。护士首先应
花粉ABO抗原
《水运建设市场监督管理办法》第十九条规定()应当按照合理工期组织项目实施,不得任意压缩合理工期和无故延长工期。
()是从重从快惩处严重刑事犯罪分子的前提。
行政追偿制度是公务员基于和国家之间的职务委托关系而对国家承担的一种行政责任,旨在确保职务关系。其所应具备的条件有()。
最新回复
(
0
)