首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Test { public: Test() {n+=2;) ~Test() {n一3;) static
有如下程序: #include using namespace std; class Test { public: Test() {n+=2;) ~Test() {n一3;) static
admin
2018-12-04
17
问题
有如下程序:
#include
using namespace std;
class Test
{
public:
Test() {n+=2;)
~Test() {n一3;)
static int getNum0{return n;}
private:
static int n;
);
int Test::n=l;
int main()
{
Test*P=new Test;
delete p;
cout<<"n"<
return O;
)
执行后的输出结果是( )。
选项
A、n=0
B、n=l
C、n=2
D、n=3
答案
A
解析
此题考查的是静态数据成员和静态成员函数。静态数据成员是类中所有对象共享的成员,而不是某个对象的成员。题目中的静态数据成员n的运算具有叠加性,执行“n+=2”和“n一3”后n的值为0。
转载请注明原文地址:https://kaotiyun.com/show/NgAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
设有以下类和对象的定义:classA{public:intm;…};Ak1,k2,*p1,*p2;则下面针对成员变量m的引用,错误的是
下列关于运算符重载不正确的是()。
设有定义:classperson{intnum;charname[10];public:voidinit(intn,char*m)};personstd[30]则以下叙述不正确的是(
假设fin是一个文件流对象,则关闭文件的语句是______。
冒泡排序算法在最好的情况下的元素交换次数为______。
下面是关于派生类声明的开始部分,其中正确的是()。
有如下定义:classMA{intvalue:public:MA(intn=0):v;alut(n){}};MA*ta,tb:其中MA类的对象名标识符是______。
关于关键字class和typename,下列说法中正确的是
下列字符串中,不可以用作C++标识符的是
随机试题
下面各项中用附加手段改变词的语法形式的是()
帕金森病的主要病理部位是
某小动物医院收治一难产母犬,手术后母犬死亡,尸体剖检,发现腹腔内有一块纱布。手术人员中应承担主要责任的是()。
某市盲目投资建设多家烟厂,生产的香烟大多销在本市。由于各厂产量过高,积压严重,该市烟叶协会组织各烟厂达成协议,每厂均减产30%。对此,下列哪些说法是正确的?()
企业发行中期票据只需披露企业主体信用评级,不需披露中期票据的债项评级。()
1,3,6,10,15,21,()
1991年某组织发表了《汉城宣言》,提出了“相互依存、共同受益,坚持开放的多边贸易体制和减少贸易壁垒”的组织宗旨和目标。该组织是()。
阅读下面短文,回答下列五道题。包括一些海洋学科普作家在内的几乎每个人都认为,在大海深处的巨大压力之下,人体会被压扁。实际上,情况似乎并非如此。由于在很大程度上我们本身也是由水组成的,而水——用牛津大学弗朗西丝.阿什克罗夫特的话来说——“______
Whenthemanaskedifhecouldpaybycheck,theassistant______.Whywasthemaninvitedintothemanager’soffice?
•Lookatthestatementsbelowandatthefiveextractsfromanarticleaboutwhattheyshouldtrytolearnandhoweffectiveorg
最新回复
(
0
)