首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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-02-22
27
问题
有如下程序:
#include<iostream>
using namespace std;
class test{
private:
int a;
public:
test(){cout<<”constructor”<<endl.}
test(int a){cout<<a<<endl;}
test(const test&_test){
a=test.a;
cout<<”copy constructor”<<endl;
}
一test(){cout<<”destructor”<<end1;}
};
int main(){
test A(3);
return 0;
}
执行这个程序的输出结果是( )。
选项
A、3
B、comtructor
destructor
C、copy constructor
destructor
D、3
destructor
答案
D
解析
本题考查默认构造函数和带参数的构造函数以及析构函数,本题中定义了一个对象A(3),对象带着参数,所以执行带参数的构造函数,输出3,然后执行析构函数,输出destructor。所以本题答案为D。
转载请注明原文地址:https://jikaoti.com/ti/yZh0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列代码段声明了3个类classPerson{};classStudent:publicPerson{};classUndergraduate:Student{};下列关于这些类之间关系的描述中,错误的是(
下列符号中不属于C++关键字的是()。
下列语句中,错误的是()。
数据库管理系统(DBMS)是一种
设有课程关系模式:R(C#,Cn,T,TA)(其中,C#为课程号,Cn为课程名,T为教师名,Ta为教师地址)并且假定不同课程号可以有相同的课程名,每个课程号下只有一位任课教师,但每位教师可以有多门课程。关系R中对主属性的传递依赖为
冒泡排序在最坏情况下的比较次数是
有如下程序:#include<iostream>usingnamespacestd;intmain(){voidfunction(doubleval);doubleval;f
下列语句分别是不同程序中的第一个输入输出语句,若去掉其中的’’<<left",输出效果将发生变化的是()。
设二叉树的前序序列为ABDEGHCFIJ,中序序列为DBGEHACIFJ。则按层次输出(从上到下,同一层从左到右)的序列为
请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程文件pmj3。本题创建一个小型字符串类,字符串长度不超过100。程序文件包括proj3.h、proj3.cpp、writeToFile.obj。补充完成重载赋值运算符函数,完成深复制功能。
随机试题
能诱导机体产生变态反应的是
在阻流截面之前封闭,然后开放的浇注系统称为封闭式浇注系统。()
关于肝血管瘤错误的是
A.造血干细胞增生和分化异常B.遗传性Hb合成异常C.慢性失血D.获得性红细胞膜缺陷E.遗传性红细胞膜缺陷缺铁性贫血
建筑单位工程概算的主要编制方法有( )。
下列关于钻孔灌注桩正循环回转法的说法正确的有()。
会计人员遵守职业道德的情况是会计从业资格证书注册登记管理的重要内容。()
我去陈先生塾馆______上学是在1940年农历二月初十。
下列关于隐形飞机的原理,说法错误的是:
Weshouldapplyourenergyto______(find)asolutiontotheproblem.
最新回复
(
0
)