首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class XA{ int a; public: static int b: XA(int aa):a(aa){b++;)
有如下程序: #include using namespace std; class XA{ int a; public: static int b: XA(int aa):a(aa){b++;)
admin
2014-08-29
31
问题
有如下程序:
#include
using namespace std;
class XA{
int a;
public:
static int b:
XA(int aa):a(aa){b++;)
~XA(){}
int get0{return a;}
);
int XA::b=0;
int main() {
XA d1(2),d2(3);
cout<
return 0:
}
运行时的输出结果是( )。
选项
A、5
B、6
C、7
D、8
答案
C
解析
执行xA类的实例变量d1(2)时,成员函数d1.get()的返回值等于2,xA.b的值等于1,执行xA类的实例变量d2(3)时,成员函数d1.get()的返回值等于3,xA-b的值等于2,所以输出结果为2+3+2=7。
转载请注明原文地址:https://kaotiyun.com/show/PWNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列程序的运行结果为()。#include<iostream>usingnamespacestd;namespacem{intflag=10;}namespacen{
下面运算符不能被友元函数重载的是()。
多重if_else语句嵌套使用时,寻找与else配套的if方法是()
算法的基本特征是可行性、确定性、【】和拥有足够的情报。
下面关于运算符重载的描述错误的是()。
按照标识符的要求,下列选项中,()符号不能组成标识符。
下列关于虚函数的描述中,正确的是()。
以下程序的输出结果是______。for(x=3;x=6;x++){cout<<((x%2)?"**":"#")<<x;if(x%2==0)cout<<end1;}
下列叙述中正确的是______。
下列关于类模板的模板参数的叙述中,错误的是
随机试题
在管理中,决策是每一个管理人员都可能要从事的活动。()
Notlongago,Ihadmyfirston-linechat.Ithoughtitwouldbe【56】because.Ihaveheardsomanypeople【57】itinthatway.But
A.支气管扩张B.肺脓肿C.慢性阻塞性肺病D.支气管哮喘发作性咳嗽、呼气性呼吸困难,伴有哮鸣音
根据健康教育诊断,不属于高可变性行为的是
A.结核球B.原发型肺结核C.肺脓肿D.结节病E.浸润型肺结核患者,男性,30岁。农民。症见低热、乏力、干咳1个月。体检:浅表淋巴结无肿大,肺部无异常体征,胸片示右肺门淋巴结肿大,诊断首先考虑
下列行为中,海关可处以1000元以上5000元以下罚款的有()。
私募基金是指只能采取非公开方式,面向特定投资者募集发售的基金。()
电子邮政系统的功能框架结构包括()。[2007年真题]
Helivedina______house,andforthisreasonhewaseasilyacceptedintohismoney-worshipingsociety.
Theflowerneeds(water)______.Otherwise,itwillwither.
最新回复
(
0
)