首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class XA { int a; public: s
有如下程序: #include using namespace std; class XA { int a; public: s
admin
2015-07-22
35
问题
有如下程序:
#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://jikaoti.com/ti/5wE0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
C++语言中的友元函数为在类外访问类中的私有成员和保护成员提供了方便,但破坏了类的______和______。
以下程序的输出是()。structst{intx;int*y;}*p;intdt[4]={
假定MyClass为一个类,则执行MyClassa[3],*p[2];语句时,自动调用该类构造函数()次。
当数据的物理结构(存储结构、存取方式等)改变时,不影响数据库的逻辑结构,从而不致引起应用程序的变化,这是指数据的【】。
已知函数f的原型是:voidf(int*a,long&b);,变量v1、v2的定义是:intv1;longv2;,正确的调用语句是______。
线性表的顺序存储结构和线性表的链式存储结构分别是()。
面向对象程序设计思想的主要特征中不包括
排序是计算机程序设计中的一种重要操作,常见的排序方法有插入排序、【】和选择排序等。
下面是关于ios类的叙述,正确的是()。
随机试题
无损测厚仪测量的准确率只与仪器有关,与操作者无关。
A、肾阳虚证B、肾阴虚证C、肾精不足D、肾气不固E、肾虚水泛腰膝酸冷,性欲减退,夜尿频多,畏寒肢冷者,可辨证为
患者男,28岁,长期便秘,每次排便时间大于30分钟。近来一周未排便,腹痛腹胀来院就诊,遵医嘱给予大量不保留灌肠。灌肠液每次的用量是
在实施监理过程中,监理单位派出的监理机构可以行使的职权有( )。
会计职业道德是对会计法律制度的重要补充。()
法治保障体系内容构成的核心在于()。
It’snosurprisethatJenniferSenior’sinsightful,provocativemagazinecoverstory,"IloveMyChildren,IHateMyLife,"isa
2010年,少儿读物进口额占图书进口总额的()
个体提高自我价值的过程,就是
Chinahasoutlinedanewapproachtoforeigninvestment,withplannerssayingtheywillnowfocuslessonattractinglargeamoun
最新回复
(
0
)