首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class XA { int a; public: s
有如下程序: #include using namespace std; class XA { int a; public: s
admin
2015-07-22
32
问题
有如下程序:
#include
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 d1(2),d2(3);
cout<
return 0;
}
运行时的输出结果是
选项
A、5
B、6
C、7
D、8
答案
B
解析
本题考查类的静态数据成员,题目中定义了类的静态数据成员b,当执行定义两个对象时执行构造函数,构造函数执行b++,所以b最终为2,而d1.get()为2,d2.get()为3,最终结果为7,C选项正确。
转载请注明原文地址:https://kaotiyun.com/show/6uNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
假定MyClass为一个类,则该类的拷贝初始化构造函数的声明语句为()。
关于动态存储分配,下列说法正确的是______。
一个类的友元函数能够访问该类的()。
关于虚函数,下列表述正确的是()。
在面向对象方法中,类之间共享属性和操作的机制称为【】。
C++中运算符优先级由高到低排列正确的是
下面程序段中,for循环的执行次数是char*s=“\ta\018bc";for(;*s!=’\0’;s++)cout<<"*";
算法的工作量大小和实现算法所需的存储单元多少分别称为算法的【】。
C++语言中标点符号中表示一条预处理命令开始的是
随机试题
肺心病急性加重期的治疗关键是
关于设备经济寿命的论述正确的有()。
背景资料某单孔防洪闸工程位于一土坝上,闸室采用涵洞式结构,闸门采用平板钢闸门。闸室主体工程施工中,部分项目划分及项目工作持续时间详见下图(每月按30天计)。问题:在进行边墩后土方回填时,混凝土与填土的结合面应如何处理?
下列关于交易型开放式指数基金的说法不正确的是()。
商用房贷款面临的信用风险不包括()。
采用成本领先战略的条件有()。
A、B两种产品共同消耗的燃料费用为16000元,A、B两种产品的定额消耗量分别为150千克和250千克。则按燃料定额消耗量比例分配计算的B产品应负担的燃料费用为()元。
小说:《死魂灵》:俄国
“化农民”与“农民化”是晏阳初进行乡村建设的途径和目标。
()是英国18世纪第一位最有影响的小说作家,其代表作有《格列佛游记》等。
最新回复
(
0
)