首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
如下程序的输出结果是 #include<iostream> using namespace std; class Test{ public: Test( ){n+=2;} ~Test( ){n-=3;} stati
如下程序的输出结果是 #include<iostream> using namespace std; class Test{ public: Test( ){n+=2;} ~Test( ){n-=3;} stati
admin
2013-05-30
49
问题
如下程序的输出结果是 #include<iostream> using namespace std; class Test{ public: Test( ){n+=2;} ~Test( ){n-=3;} static int getNum( ){return n;} private: static int n; }; int Test::n=1; int main( ){ Test*P=new Test: delete P; cout<<"n="<<Test::getNum( )<<endl; return 0; }
选项
A、n=0
B、n=1
C、n=2
D、 n=3
答案
A
解析
静态数据成员的初始值n=1,执行Test*p=new Test;,调用构造函数后,n= 3,deletep;调用析构函数,n-=3,所以最终n=0。
转载请注明原文地址:https://kaotiyun.com/show/VnNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
某二叉树中度为2的结点有n个,则该二叉树中有【】个叶子结点。
若有以下程序:#include<iostream>usingnamespacestd;classA{private:intx;public:intz;voidsetx(inti){x=i;}intgetx
有如下说明inta[10]={1,2,3,4,5,6,7,8,9,10},*p=a;则数值为9的表达式是()。
在下面横线上填上适当的语句,完成程序。#include<iostream>usingnamespacestd;classBase{intx;public:Base(inti){x=i;}~Base()
MyClock类的拷贝构造函数的声明语句为()。
有如下程序:#include<iostream>usingnamespacestd;intfun(inta,intb){return(++a*b++);}voidmain(){
阅读下面程序:#include<iostream.h>voidmain(){inti,j,row=0,column=0,m;staticinta[3][3]={100,28,72,-30,2,-100};
软件工程包括三个要素,分别为方法、工具和【】。
有如下程序段:intx=3,do{x-=2;cout<<x;}while(!(--x));执行这个程序段的输出结果是()。
以下程序的执行结果是【】。#include<iostream.h>#include<stdlib.h>classSample{public:intx,y;Sample(){x=y=0;}
随机试题
PowerPoint2010的一大特色就是可以使演示文稿的所有幻灯片具有统一的外观,下列()不能更改幻灯片的外观。
《中华人民共和国反倾销条例》的规定,临时反倾销措施实施的期限,自临时反倾销措施决定公告实施之日起不得超过()个月,特殊情形下可延长至()个月?
需要办理注销登记的情形包括( )。
根据《企业破产法》的规定,下列有关和解的表述中,正确的是()。
下列关于劳动争议基本特征的表述错误的是()。
【2015年】下列舞弊风险因素中,与编制虚假财务报告相关的有()。
强调概括化经验在迁移中的作用的理论是()。
—个三位数,各位数字之和为10,这样的三位数有多少个?
全国人民代表大会的职权不包括()。
1935年12月,中共中央政治局在陕北瓦窑堡召开政治局会议上,提出了党的抗日民族统一战线的新政策。会议主要内容有()
最新回复
(
0
)