首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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-06-10
20
问题
有如下程序:
#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/V5fp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#includeusingnamespacestd;classA{public:A(inti=0):r1(i){}voidprint(){cout
有如下程序:撕ncludeusingnamespacestd;classAA{intk;protected:intn;voidsetK(intk){this一>k=k;}public:voidsetN(intn){thi
软件设计中模块划分应遵循的准则是
在关系模型中,每一个二维表称为一个()。
若有以下定义,说法错误的是()。inta=100,*p=&a;
若有以下程序:#include<iostream>usingnamespacestd;intfun(){staticinti=0;ints=1;s+=i;i++;r
有如下类定义classMyClasspublic:Private:intdata;};若要为MyClass类重载流输入运算符>>,使得程序中可以“cin>>obj;”形式输入MyClass类的
下列关于派生类构造函数和析构函数的说法中,错误的是()。
请使用VC6或使用【答题】菜单打开考生文件夹pmjl下的工程projl,其中在编辑窗口内显示的主程序文件中定义有类ABC和主函数main。程序文本中位于每行“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应
数据库系统在其内部具有3级模式,用来描述数据库中全体数据的全局逻辑结构和特性的是()。
随机试题
总价合同和单价合同在报价形式上很相似,都要报出各项单价,并以工程量表中的工程量乘以各项单价之和形成合同总价,但两者在性质上完全不同,总价合同特点有()。
“3Q”育人模式中,基层管理者的育人方式是()
已知f’(x)=,且f(1)=2,则f(x)=______.
氟烷属于
关于对圆管涵在安装管节时的注意事项,错误的是()。
立卷是指按照一定的原则和方法,将有保存价值的文件分门别类整理成案卷,亦称组卷。下列选项中关于立卷的基本原则说法正确的有()。施工文件档案管理的内容主要包括()。
下列关于重力式挡土墙说法正确的有()。
我国唯一一条注入北冰洋的河流是:
根据以下资料,回答91~95题2007年上半年某镇完成工业总产值66625万元,比去年同期增长32.7%,增速提高12.7个百分点。其中规模以上工业企业完成产值56869万元,比上年同期增长43.9%,占全年工业总产值计划的45.3%。完成工业增加值22
已知A为三阶方阵,A2—A—2E=D,且0<|A|<5,则|A+2E|=________。
最新回复
(
0
)