首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
53
问题
有如下程序:
#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全国计算机二级
相关试题推荐
请打开考生文件夹下的解决方案文件proj1,其中定义了一个CD类。程序中位于每个//ERROR**********found**********下的语句行有错误,请加以更正,不得修改程序的其他部分。更正后程序的输出应该是:歌唱祖国30义
请打开考生文件夹下的解决方案文件proj3,其中包含主程序文件main.cpp和用户定义的头文件Array.h,整个程序包含有XArray类的定义和main主函数的定义。请把主程序文件中的XArray类的成员函数sum()的定义补充完整,补充的内容填写在"
请打开考生文件夹下的解决方案文件proj1,其中在编辑窗口内显示的主程序文件中定义有Xabc类和主函数main。在程序文本中位于每行”//ERROR*********found*********下面的一行有错误,请加以更正。更正后程序的输出为:
有如下程序:#include<iostream>usingnamespacestd;classToy{public:Toy(char*_n){strcpy(name,_n);count++;}
有如下程序:#inc1ude<iostream>#inc1ude<iomanip>usingnamespacestd;intmain(){ints[]={123,234};cout<
有如下两个类定义classxx{private:dOublex1;protected:doublex2;public:doublex3;};classYY:
有如下程序:classBase{public:intdata;};classDerivedl:publicBasef};};classDerived2:protectedBa
在软件开发中,需求分析阶段产生的主要文档是()。
如果利用C++流进行输入输出,下面的叙述中正确的是()。
随机试题
脊柱叩击痛的检查方法及临床意义正确的是
腮腺管口红肿,按摩肿胀腮部无脓水流出者称为
下列关于法律原则和法律规则的适用的说法,正确的有:
()属于合同法律行为。
下列不属于账账核对的项目有()
能把旋转运动变为往复直线运动,也可以把往复直线运动变为旋转运动的机构是()。
根据《公司法》的规定,公司的组织变更( )。
伊斯兰教的经典是《可兰经》。
ThementalhealthmovementintheUnitedStatesbeganwithaperiodofconsiderableenlightenment.DorotheaDixwasshockedtof
Oldpeoplearealwayssayingthattheyoungarenotwhattheywere.Thesamecommentis【C1】______fromgenerationtogenerationa
最新回复
(
0
)