首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
34
问题
有如下程序:
#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
desiructor
D、3
destructor
答案
D
解析
本题考查默认构造函数和带参数的构造函数以及析构函数,本题中定义了一个对象A(3),对象带着参数,所以执行带参数的构造函数,输出3,然后执行析构函数,输出destructor。所以本题答案为D。
转载请注明原文地址:https://kaotiyun.com/show/yNfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
请打开考生文件夹下的解决方案文件proj1,此工程中包含一个源程序文件main.cpp,其中有类Book(“书”)和主函数main的定义。程序中位于每个“//ERROR****found****”下的语句行有错误,请加以改正。改正后程序的输出结果应该是:
有如下程序:#includeusingnamespacestd;classBase{public:virtualvoidShow(){cout
下列关于析构函数的描述中,错误的是()。
有如下程序:#includeusingnamespacestd;classA{public:A(){cout
有如下程序:#includeusingnamespacestd;classSample{friendlongfun(Samples);public:Sample(long
有如下类定义和变量定义:c1assA{public:A(){data=0;}~A(){}intGetData()const{retumdata;}voidSetData(int
已知将运算符’’+’’和’’*’’作为类Complex的成员函数重载,设c1和c2是类Complex的对象,则表达式c1+c2*c1等价于()。
下列定义语句中,错误的是()。
下列哪项不是面向对象程序设计的主要特征()。
在数据库设计中,将E-R图转换成关系数据模型的过程属于
随机试题
Whatarethespeakersmainlytalkingabout?
设函数f(x)=ax3+bx2+cx-9具有如下性质:(1)在点x=-1的左侧临近单调减少;(2)在点x=-1的右侧临近单调增加;(3)其图形在点(1,2)的两侧凹凸性发生改变。试确定a,b,c的值。
如下哪项不适于顽固性心力衰竭的治疗
A.玫瑰疹B.皮肤淤点、淤斑C.淋巴结肿大D.关节痛E.少尿流行性脑脊髓膜炎可有()
关于商业银行贷款法律制度,下列哪一选项是错误的?(卷一/2008年第23题)
计算不规则及多边形钢板质量应按其()。[2006年真题]
证券公司承销证券,应当同发行人签订代销或者包销协议。证券的代销、包销期限最长不得超过()日。
心理特性包括
下列各类计算机程序语言中,不属于高级程序设计语言的是()。
Experiencetwogreattheme(主题)parksinonegreatscenicspots—Disney’sCaliforniaAdventureparkandrightnextdoorDisneyland
最新回复
(
0
)