首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; class XA { int a; public: static intb: XA(int aa):a
有如下程序: #include<iostream> using namespace std; class XA { int a; public: static intb: XA(int aa):a
admin
2020-07-30
9
问题
有如下程序:
#include<iostream>
using namespace std;
class XA {
int a;
public:
static intb:
XA(int aa):a(aa){b++;}
~XA(){}
int get(){return a;}
};
int XA::b=0;
int main() {
XA dl(2),d2(3);
cout<<d1.get()+d2.get()+XA::b<<end1;
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/LDyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列有关运算符重载的叙述中,正确的是()。
有如下程序:#include<iostream>#include<cstring>usingnamespacestd;classXCF{inta:public:XCF(intaa=0):a(aa){cout<<"1";}XCF(X
下列叙述中正确的是()。
当使用ifstream流类定义一个流对象并打开一个磁盘文件时,文件的默认打开方式为()。
有如下程序段:inti=0,j=1;int&r=i;//①r=j;//②in*p=&i;//③*p=&r;//④其中会产生编译错误的语句是()。
在公有继承的情况下,允许派生类直接访问的基类成员包括()。
有如下程序:#include<iostream>usingnamespacestd;classMonkey{public:Monkey(){cout<<’M’;}Monkey(charn){cout<<n;}~Monkey(){cou
若有如下类声明classMyClass{public:MyClass(){cout<<1;}};执行下列语句MyClassa,b[2],*p1[]2:以后,程序的输出结果是()。
下列选项中不属于面向对象程序设计特征的是()。
下面关于派生类的描述中错误的是()。
随机试题
所有细胞膜的主动转运,其能量来源是高能磷酸键的水解。()
角膜炎除眼痛外一般不会出现
临床上最常见的心律失常为
桥面较宽、跨度较大的斜交桥和弯桥宜选用的桥型是下列的()。
实行监理的建设工程,允许建筑材料、建筑构配件和设备在工程上使用或者安装的必要前提是()。
下列关于偶然所得纳税的说法中,错误的是( )。
甲公司将持有的乙公司20%有表决权的股份作为长期股权投资,并采用权益法核算。该投资系甲公司2010年购入,取得投资当日,乙公司各项可辨认资产、负债的公允价值与其账面价值均相同。2011年12月25日,甲公司以银行存款1000万元从乙公司购入一批产品,作为存
劳动法基本原则的作用是()。
下列关于计费管理的说法错误的是_______。
ThethirteenredandwhitestripesintheAmericanflagstandfor______.ThedecorationofAmericanflagsistoshow______.
最新回复
(
0
)