首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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-12-14
37
问题
有如下程序:
#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://jikaoti.com/ti/Sdt0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
常用的软件结构设计工具是结构图(SC),也称程序结构图。其中,用矩形表示______,用带空心圆的箭头表示传递的是数据。
用树形结构表示实体之间联系的模型是
一个双目运算符作为类的成员函数重载时,重载函数的参数表中有【】个参数。
根据程序中的注释将下列缺失部分补充完整。classPoint{intx,y;//点的x和y坐标public:Point(intxx=0,intyy=0):x(xx),y(yy){}};
以下对C/C++语言函数的描述中,正确的是
数据流图用于抽象描述一个软件的逻辑模型,数据流图由一些特定的图符构成。下列图符名标识的图符不属于数据流图合法图符的是
软件生命周期包括8个阶段。为了使各时期的任务更明确,又可分为3个时期:软件定义期、软件开发期、软件维护期。编码和测试属于______期。
下面是复数类complex的定义,其中重载的运算符“+”的功能是返回一个新的复数对象,其实部等于两个操作对象实部之和,其虚部等于两个操作对象虚部之和;请补充完整。classcomplex{doublereal;//实部
在函数中,可以用auto、extern、register和static这四个关键字中的一个来说明变量的存储类型,如果不说明存储类型,则默认的存储类型是()。
随机试题
根据国际生产折中理论,某企业只选择以技术转让方式参与国际经济贸易,则该企业具备的优势是()。
以上哪项为实现有效气体交换的通气量( )
A.与雌激素有关B.与人乳头瘤病毒感染有关C.与子宫内膜增生过长有关D.子宫内膜种植学说E.与细菌感染有关子宫肌瘤的病因()
下列关于动产质押贷款正确的是()
乙公司是一家上市公司,当前每股市价30元。市场上有两种以该股票为标的资产的期权:欧式看涨期权和欧式看跌期权。每份看涨期权可买入1股股票,每份看跌期权可卖出1股股票;看涨期权每份6元,看跌期权每份3元。两种期权执行价格均为28元,到期时间均为6个月,若不考虑
以“高投入、高消耗、高污染、低质量、低效益、低产出”为特征的主要发展方式仍占领着中国制造业的主导地位,虽然增加值居世界第四位,但环境污染和资源匮乏是悬在中国制造业头上的两把利剑。据世界银行估计,环境污染给中国带来相当于3.5%一8%的GDP损失。这启示我们
以下叙述中正确的是
下列运算符中不能在C++中重载的是()。
下列If语句的功能是统计性别为男、职称为副教授以上且年龄小于40岁的人数,错误的语句是()。
HerFrenchwassolimitedthatshefounditdifficultto______herideas.
最新回复
(
0
)