首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class XA { int a; public: s
有如下程序: #include using namespace std; class XA { int a; public: s
admin
2015-07-22
21
问题
有如下程序:
#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
答案
C
解析
本题考查类的静态数据成员,题目中定义了类的静态数据成员b,当执行定义两个对象时执行构造函数,构造函数执行b++,所以b最终为2,而d1.get()为2,d2.get()为3,最终结果为7,C选项正确。
转载请注明原文地址:https://kaotiyun.com/show/5fNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
按照“后进先出”原则组织数据的数据结构是
插入排序算法的主要思想是:每次从未排序序列中取出一个数据,插入到己排序序列中的正确位置。InsertSort类的成员函数sort()实现了插入排序算法。请将画线处缺失的部分补充完整。classInsertSort{public:I
有如下定义:classMA{intvalue;public:MA(intn=0):value(n){}};MA*ta,tb;其中MA类的对象名标识符是【】。
线性表的存储结构主要分为顺序存储结构和链式存储结构。队列是一种特殊的线性表,循环队列是队列的【 】存储结构。
在面向对象方法中,实现信息隐蔽是依靠
建立一个有成员对象的派生类对象时,各构造函数体的执行次序为( )。
假设用一个长度为50的数组(数组元素的下标从0到49)作为栈的存储空间,栈底指针bottom指向栈底元素,栈顶指针top指向栈顶元素,如果bottom=49,top=30(数组下标),则栈中具有【】个元素。
栈和队列通常采用的存储结构是【】。
mystrlen函数的功能是计算str所指字符中的长度,并作为函数值返回,请填空。intmystrlen(char*str){inti;for(i=0;【】!=’\0’;i++);return(i);}
数据库、数据库系统和数据库管理系统之间的关系是()。
随机试题
什么叫指状加热器?怎样操作?
阅读《郑伯克段于鄢》中的一段文字,回答下列问题:既而大叔命西鄙北鄙贰于己。公子吕曰:“国不堪贰,君将若之何?欲与大叔,臣请事之,若弗与,则请除之,无生民心。”公白:“无庸,将自及。”大叔又收贰以为己邑,至于廪延。子封曰:“可矣,厚将得众。”公曰:
女性,50岁,自称“黏液脓血便”1个月,每天3—4次,伴下腹部深在疼痛、里急后重感及乏力。根据大便化验曾按“痢疾”治疗2周,疗效不明显。应首选的进一步检查是
作痰液细菌学检查时,收集标本时应注意()。
患者,女,49岁。月经或前或后,烘热出汗,五心烦热,头晕耳鸣,腰酸乏力,舌红苔薄,脉细数。治疗应首选()
《城市房屋拆迁管理条例》规定,申请领取房屋拆迁许可证的,应当向房屋所在地的市、县人民政府房屋拆迁管理部门提交资料,其中不包括()。
建设项目后评价的主要内容包括( )。
为满足要求工期,在对工程网络计划进行工期优化时应( )。
2001年,甲(男)20岁,乙(女)19岁时举办结婚仪式,但一直未办结婚登记,后于2005年双方补办结婚登记。2005年,甲继承其叔父在台湾的遗产10万元。2007年3月,双方因感情破裂,准备离婚。下列说法正确的是()。
以下叙述中错误的是
最新回复
(
0
)