首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; class test{ private: int a; public; test(){cout<<"con
有如下程序: #include<iostream> using namespace std; class test{ private: int a; public; test(){cout<<"con
admin
2021-06-10
23
问题
有如下程序:
#include<iostream>
using namespace std;
class test{
private:
int a;
public;
test(){cout<<"constructor"<<end1;}
test(int a){cout<<a<<end1;}
test(const test&_test){
a=test.a:
cout<<"copy constructor"<<end1;
}
~test(){cout<<"destructor"<<end1;}
};
int main(){
test A(3);
return 0;
}
执行这个程序的输出结果是( )。
选项
A、3
B、constructor
C、copy constructor
D、3
答案
D
解析
本题考查默认构造函数和带参数的构造函数以及析构函数,本题中定义了一个对象A(3),对象带着参数,所以执行带参数的构造函数,输出3,然后执行析构函数,输出destrnctor。所以本题答案为D。
转载请注明原文地址:https://jikaoti.com/ti/Wwh0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
假定一个类的构造函数为A(intaa,intbb){a=aa--;b=a*bb;},则执行Ax(4,5);语句后,x.a和x.b的值分别为()。
已知函数FA调用函数FB,若要把这两个函数定义在同一个文件中,则()。
下列有关指针的用法中,错误的是()。
使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。函数convert(char*des,char*str,charc,char*str2)的功能是:如果str中包含字符“!”,则替换成’a’;
请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2。该工程中包含一个程序文件main.cpp,其中有类Quadritic、类Root及主函数main的定义。一个Quadritic对象表示一个aχ2+bχ+c的一元二次多项式。一个Roo
在一个派生类对象结束其生命周期时()。
对长度为n的线性表排序,在最坏情况下,比较次数不是n(n-1)/2的排序方法是
软件测试的目的是()。
软件测试的目的是()。
随机试题
曲线y=x/2+(x-2)3的拐点坐标是________.
孕妇尿中与胎儿胎盘功能密切的激素是
对疑有心内黏液瘤的患者,超声诊断主要应用的技术进行确诊的是
地图按照图上表示的内容可以分为()。
根据《环境影响评价技术导则生态影响》(HJ19-2011),生态现状调查的范同应()。
施工人员对涉及结构安全的试块、试件以及有关材料,应当在()的监督下现场取样,并送具有相应资质等级的质量检测单位进行检测。
某企业6月份发生下列经济业务,要求编制有关会计分录。以银行存款3000元支付销售产品的销售费用。
从每年的1月1日起至同年的12月31日止的预算年度称为()。
当今时代,我们的劳动可分为两部分:一是为得到今天生存所必需的生活资料而付出的劳动;二是为未来的发展而预先支付的劳动。当两者的比例前者大于后者时,说明我们的劳动尚处在较低级阶段;而后者远大于前者时,则说明我们的劳动层次得到了很大提高。因此,只有通过社会发展、
为了更好地理解人类个性的特征及其发展,一些心理学家对动物的个性进行了研究。以下各项如果为真,都能对上述行为提供解释,除了()。
最新回复
(
0
)