首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include #include using namespace std; class MyBag{ public: MyBag(string b
有如下程序: #include #include using namespace std; class MyBag{ public: MyBag(string b
admin
2021-02-22
16
问题
有如下程序:
#include
#include
using namespace std;
class MyBag{
public:
MyBag(string br,string cr):brand(br),color(cr) { ++count; }
~MyBag() { --count; }
static int GetCount() { return count; }
private:
string brand,color;
static int count;
};
int MyBag::count=0;
int main(){
MyBag one("CityLife","Gray"),two("Micky","Red");
_____________________
return 0;
}
若程序运行时的输出结果为 2,则横线处缺失的语句不可能是
选项
A、cout<
B、cout<
C、cout<
D、cout<
答案
B
解析
本题考查静态数据成员和静态成员函数,静态成员函数只能使用本类中的静态数据成员,且静态成员函数不归属任何一个对象,而是属于类,题目中要求输出2,那么就要将count输出,题目中定义了两个对象,都对count进行了++,所以调用静态成员函数直接使用类名,B选项正确。
转载请注明原文地址:https://jikaoti.com/ti/oZh0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
定义学生选修课程的关系模式:SC(S#,Sn,C#,Cn,G)(其属性分别为学号、姓名、课程号、课程名、成绩)则该关系的主键为
数据库管理系统的基本功能不包括
软件生命周期可分为定义阶段、开发阶段和维护阶段,下面属于开发阶段任务的是
下列描述中错误的是
对于长度为n的线性表,在最坏情况下,下列各排序法所对应的比较次数中正确的是
软件按功能可以分为:应用软件、系统软件和支撑软件(或工具软件)。下面属于系统软件的是
下列运算符中,不能被重载的是()。
请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,此工程中含有一个源程序文件proj1.epp。其中位于每个注释“//ERROR****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:C
下列关于运算符函数的叙述中,错误的是()。
请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,此工程中声明的Array是一个表示数组的类。一个Array对象可以包含多个整型元素。A唧的成员说明如下:成员函数add用于向数组的末尾添加一个元素;成员函数get
随机试题
某市公安局于2016年1月4日对刘某(男,24岁)、张某(男,21岁)持刀抢劫致人重伤一案立案侦查。经侦查查明,刘某、张某实施抢劫犯罪事实清楚,依法应当追究刑事责任。刘某、张某抢劫案于2016年3月30日侦查终结,移送市人民检察院审查起诉。市人民检察院审查
中国金融期货交易所不得对投资者适当性标准进行调整。()
下列税种中,纳税人自己承担税负,不发生转嫁关系的是()。
根据规定,导游人员不保管旅游者的证件,但老年旅游者的证件应例外对待,为安全起见,全陪应负起责任,集中保管他们的证件。()
教育教学活动取得成功的必要保证是良好的()
根据以下资料,回答下列121~125题。2006—2008年,该省平均每年进出口总额约为()。
光纤作为传输介质的主要特点是()。Ⅰ.保密性好Ⅱ.高带宽Ⅲ.低误码率Ⅳ.拓扑结构复杂
若有下面的函数调用:fun(a+b,3,max(n一1,b))则fun的实参个数是()。
Agreatdealofattentionisbeingpaidtodaytotheso-calleddigitaldivide—thedivisionoftheworldintotheinfo(informatio
Man-madeclimatechangeis"unequivocal(毋庸置疑的)"anddemandsurgentaction.Yesterday’sreportfromtheIntergovernmentalPanelo
最新回复
(
0
)