首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
2017-02-18
57
问题
有如下程序:
#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://www.kaotiyun.com/show/UIAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
检查软件产品是否符合需求定义的过程称为
包容类Contain和内嵌类Embed定义如下:#include<iostream.h>classContain{private:intX;protected:intz;public:
以下程序的输出结果是#include<iostream.h>voidmain(){charx=040;cout<<(X<<1);}
下列函数的运行结果是#include<iostream.h>intf(inta,intB){intc;if(a>b)c=1elseif(a=b)c=0;
以下程序的输出结果是【】。#include<iostream.h>unsignedfun(unsignednum){unsignedk=1;do{k*=num%10;n
模块独立性是软件模块化所提出的要求,衡量模块独立性的度量标准则是模块的
C++语言中关于构造函数的说法正确的是
下列语句段将输出字符’*’的个数为inti=100;while(1){i--;if(i==0)break;cout,,’*’;}
关于函数中的,下列表述中错误的是()。
下列关键字不能作为函数返回值类型的是( )。
随机试题
试述肠梗阻的腹部体征。
据《素问.异法方宜论》,中央之域人们的饮食特点是
对于输尿管结石引起梗阻而致的肾功能明显受损,应采取的措施是
环丙沙星的化学名为
根据《标准施工招标文件》(2007版)通用合同条款,承包人可能同时获得工期和费用补偿、但不能获得利润补偿的索赔事件有()。【2016年真题】
在会计核算过程中,会计处理方法前后各期()。
我国社会主义经济制度的基础是()。
窗体上有一个Textl文本框,并编写了下面事件过程:PrivateSubTextlKeyPress(KeyAsciiAsInteger)KeyAscii=KeyAscii+3EndSub程序运行时,在文本框中输入字符“A”,则在文本框中
Atwhattimeoftheyeardoesthisinterviewtakeplace?
A、Itisinterestingandcomfortable.B、Helikestoliveinabigcity.C、Itneedsmoremoneytolivehere.D、Itisdifficultto
最新回复
(
0
)