首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
13
问题
有如下程序:
#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 main(){
MyBag one("CityLife","Gray"),two("Micky","Red");
cout<
return 0;
}
若程序运行时的输出结果为 2,则横线处缺失的语句是
选项
A、intcount=0;
B、staticintcount=0;
C、intMyBag::count=0;
D、staticintMyBag::count=0;
答案
C
解析
本题考查构造函数和析构函数,以及静态数据成员,题目中要求输出2,那么定义两个对象时,就执行构造函数,使得静态数据成员++count,得到2,那么count初始化就应该为0,静态数据成员初始化时,只能在类体外进行初始化,一边形式为:数据类型类型::静态数据成员名=初值
转载请注明原文地址:https://jikaoti.com/ti/Leh0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
将E-R图转换为关系模式时,实体和联系都可以表示为
有三个关系R、S和T如下:则由关系R和S得到关系T的操作是
有三个关系R、S和T如下:由关系R和S通过运算得到关系T,则所使用的运算为
有如下程序:#include<iostream>usingnamespacestd;classA{public:A(inti){x=i;}voiddispa,(){cout<<x<<
设有课程关系模式:R(C#,Cn,T,TA)(其中C#为课程号,Cn为课程名,T为教师名,Ta为教师地址),并且假定不同课程号可以有相同的课程名,每门课程只有一位任课教师,但每位教师可以有多门课程。关系R范式最高达到
将数据库的结构划分成多个层次,是为了提高数据库的逻辑独立性和
在下面的4个关键字中用来说明虚函数的是()。
模板对类型的参数化提供了很好的支持,因此()。
使用VC6打开考生文件夹proj3下的工程proj3,其中定义了一个字符串变量类StringVar。类成员的说明在程序注释中。请在//**********333**********和//*****666*****之间填写StringVar成员函数和友元函数
在快速排序法中,每经过一次数据交换(或移动)后
随机试题
全身炎症反应综合症的主要表现为()
内脏痛最主要的特点是
临床中进行肥达试验最常采用的方法为
预应力混凝土悬臂梁、连续梁、刚构、斜拉桥等结构都可采用()施工方法。
()的经营形式税负最重。
统计调查对象中,必须取得统计从业资格、持有统计从业资格证书的人员是()。
甲公司存货采用计划成本核算,2019年3月1日“原材料一A材料”借方余额为2900000元,“材料成本差异”贷方余额为22000元。当月采购A材料一批,取得货物增值税专用发票注明的价款为5522000元,增值税税额为883520元,全部验收入库。该批原材料
剩余权益收益等于()。
某夫妻二人因为感情不和提出离婚,那么二人在诉讼离婚时必经的庭审程序是()
关于诉讼时效制度的表述,正确的是()。
最新回复
(
0
)