首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #inc1ude <iostream> using namespace std; class XA{ int a; public: static int b; XA(int aa):a
有如下程序: #inc1ude <iostream> using namespace std; class XA{ int a; public: static int b; XA(int aa):a
admin
2018-12-04
19
问题
有如下程序:
#inc1ude <iostream>
using namespace std;
class XA{
int a;
public:
static int b;
XA(int aa):a(aa){b++;}
~XA(){}
int get() {return a;}
};
int XA::b =0;
int main() {
XA dl(2),d2(3);
cout<<dl.get()+d2.get()+XA::b<<endl;
return 0:
}
运行时的输出结果是( )。
选项
A、5
B、6
C、7
D、8
答案
C
解析
执行XA类的实例变量d1(2)时,成员函数dl.get()的返回值等于2,XA.b的值等于1,执行XA类的实例变量d2(3)时,成员函数dl.get0的返回值等于3,XA.b的值等于2,所以输出结果为2+3+2=7。
转载请注明原文地址:https://kaotiyun.com/show/PrAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#include<iostream>usingnamespacestd;classMyClass{public:MyClass(intx):val(x){}void
在关系数据库中,用来表示实体之间联系的是______。
有以下程序main(){inti=10,j=1;cout<<--<<","<<++j<<endl;}执行后输出结果是
下述关于数据库系统的叙述中正确的是
数据流图用于抽象描述一个软件的逻辑模型,数据流图由一些特定的图符构成。下列图符名标识的图符不属于数据流图合法图符的是
已知类A有公用数据成员a,并重载了=运算符,且有Aobj2;constAptr*=newA;则下列语句错误的是
下列关于完全二叉树的叙述中,错误的是()。
下列不属于软件工程3个要素的是( )。
随机试题
下列有关股票发行的说法,正确的是:()
某28岁妇女,已自然流产2次,现停经4个半月,阴道流血2个多月。为保胎一直拒绝妇科检查。此病人治前首先检查
记账凭证账务处理程序的主要缺点是( )。
对外加工装配业务与来料加工均为一进一出的两笔交易。()
假设某外币资产1天的风险价值VaR在99%的置信区间内为1万美元,则其对应的10天的风险价值VaR最接近于()。
Themassmediainfluencesall【C1】______ofourlives,includingthelearningof【C2】______roles.Newspapersandmagazines,televis
如何应用销售百分比法预测资金需要量?
CHINESEMEDICINE
Listentothefollowingpassage.WriteinEnglishashortsummaryofaround150-200wordsofwhatyouhaveheard.Youwillhear
Theresultsarehardly______;hecannotbelievetheyareaccurate.
最新回复
(
0
)