首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
N610060099) 有如下程序: #include #include using namespace std; class MyBag{ public: My
N610060099) 有如下程序: #include #include using namespace std; class MyBag{ public: My
admin
2020-07-23
24
问题
N610060099) 有如下程序:
#include
#include
using namespace std;
class MyBag{
public:
MyBag(string br,string cr):brand(br),color(cr) { cout<<++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");
MyBag *ptr=new MyBag("Coach","Black");
delete ptr;
cout<
return 0;
}
运行时的输出结果是
选项
A、2
B、3
C、1232
D、1233
答案
C
解析
本题考查静态数据成员和构造函数和析构函数,题目中定义了三个对象,那么一次输出count值,即123,销毁ptr后,执行析构函数,count减1 ,count为2,所以选项C正确。
转载请注明原文地址:https://kaotiyun.com/show/gGyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列关于类定义的说法中,正确的是()。
算法的空间复杂度是指( )。
在一个有参函数的原型声明中可有可无的语法成分是
有如下程序:#includeusingnamespacestd;intmain(){intsum;for(inti=0;i<3;i+=
下列关于运算符重载的叙述中正确的是
派生类的成员函数不能访问的基类的成员是
下列选项可以做C++标识符的是()。
有如下程序:运行这个程序时,若输入字符串为:abcdefgabed则输出结果是()。
数据库设计中反映用户对数据要求的模式是()。
一间宿舍可住多个学生,则实体宿舍和学生之间的联系是()。
随机试题
在大多数情况下,企业面临的市场环境在不断地发生变化。由于这种变化,市场的需求也在变化,并且处于一个不稳定的状态中。市场需求越不稳定,越需要精确的预测。准确地预测市场需求是企业成功的关键环节之一。因为任何错误的预测都可能导致诸如库存积压或者是存货严重不足,从
患者,女,16岁,右上侧切牙冠折2/3,咬合关系正常.患牙经根管治疗后.最好选用哪种桩冠修复
患儿,女,8岁,低热、轻咳3周。查体:体温38.2℃,营养差,右背下部听诊呼吸音减低,接种过卡介苗,PPD试验(+++)。其弟3岁,无症状,但PPD试验(+++),胸片正常,宜采取的措施是()
甲乙在讨论普通合伙企业的有关规定,甲说在普通合伙企业中任何情况下,合伙人都应该按照法律规定对合伙企业债务承担无限连带责任。甲的观点是正确的。()
感觉动作思维主要凭借______进行,______停止,思维就停止。
Therearesofewmembersofsomeplantspeciesleftthattheyareindangerofbecoming________.
一项对独立制作影片的消费调查表明,获得最高评价的动作片的百分比超过了获得最高评价的爱情片的百分比。但是,调查方由此得出的电影主题决定了影片的受欢迎程度的结论却很可能是错误的,因为动作片都是由那些至少拍过一部热门影片的导演执导,而爱情片都是由较新的导演制作,
Lookatthestatementsbelowandthefiveextractsfromanarticleabout"Dilution"ofcontrolinwardandoutward.Whicharticle
Theprofessorgave______instructionforcarryingouttheresearchproject.
Itwasreportedthatonlyonepassengerwasfortunatetoescape______intheplanecrash.
最新回复
(
0
)