首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class test { private: int a; public: test() { cout
有如下程序: #include using namespace std; class test { private: int a; public: test() { cout
admin
2021-05-06
82
问题
有如下程序:
#include
using namespace std;
class test {
private:
int a;
public:
test() { cout<<"constructor"<
test(int a) { cout<
test(const test &_test) {
a=_test.a;
cout<<"copy constructor"<
}
~test() { cout<<"destructor"<
};
int main() {
test A(3);
return 0;
}
执行这个程序的输出结果是( )。
选项
A、3
B、constructor
destructor
C、copy constructor
destructor
D、3
destructor
答案
D
解析
本题考查默认构造函数和带参数的构造函数以及析构函数,本题中定义了一个对象A(3),对象带着参数,所以执行带参数的构造函数,输出3,然后执行析构函数,输出destructor。所以本题答案为D。
转载请注明原文地址:https://kaotiyun.com/show/mDfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下类定义:classSample{public:Sample(intx):ref(x){}//①Sample():ref
下列因素中,对C++编译器区分重载函数无任何意义的是
有3个关系R、S和T如下:则由关系R、S得到关系T的操作是()。
要使程序的输出结果为Base,则在横线处填写的派生类Derived的继承方式是()。#includeusingnamespacestd;classBase{public:voidprint(){cout
有如下类说明:classTestClass{intx:public:TestClass(intn){x=n;}};classTestClass1:publicTestClass{inty;public:TestClass1(i
下面描述中,不属于软件危机表现的是()。
如果利用C++流进行输入输出,下面的叙述中正确的是()。
下面是关于派生类声明的开始部分,其中正确的是()。
下面不属于软件测试实施步骤的是()。
随机试题
简析汤显祖《牡丹亭》(惊梦)(节选)的主旨。
SomeUScollegesadoptadifferentapproach."Wewouldallliketosaywedonotcarehowmuchparentsgive,intheformofdona
日常上楼的MET为
A.应当至少检查一个最小包装B.可不开箱检查C.应当检查箱内的所有最小包装D.可不打开最小包装根据2013年1月发布的《药品经营质量管理规范》药品批发企业对同一批号药品的验收要求是
2006年9月20日,中国A市甲公司作为买方与作为卖方的位于意大利B市的乙公司在北京签订购买由意大利丙公司生产的钢琴1万架的合同。后来,钢琴按时运抵甲公司,但甲公司验货后发现该批钢琴质量存在严重缺陷,于是甲公司要求乙公司退还相应的货款并赔偿由此造成的损失。
借助货币资金供应总量的变化影响宏观经济的发展规模和速度指的是金融市场的()。
下列创建文件夹的操作中,错误的是()。
SoBig.Fwasthemorevisibleofthetworecentwavesofinfectionbecauseitpropagateditselfbye-mail,meaningthatvictims
HeisnowinLondon,buthemissedhisparents_____enjoytheexcitinglifethere.
CorporationsAcorporationisakindofbusinessorganizationwithanunlimitedlifetime./Corporationscansellstocka
最新回复
(
0
)