首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; class TestClass{ static int i; public: TestClass(){i++;
有如下程序: #include<iostream> using namespace std; class TestClass{ static int i; public: TestClass(){i++;
admin
2012-01-20
54
问题
有如下程序: #include<iostream> using namespace std; class TestClass{ static int i; public: TestClass(){i++;} ~TestClass(){i--;} static int getVal(){return i;} }; int TestClass::i=0; void f(){TestClass obj2;cout<<obj2.getVal();} int main(){ TestClass obj 1; f(); TestClass *obj3=new TestClass;cout<<obj3->getVal(); delete obj3;cout<<TestClass::getVal(); return 0; } 程序的输出结果是( )。
选项
A、232
B、221
C、222
D、231
答案
B
解析
有如下程序: #include<iostream> using namespace std; class TestClass{ static int i; public: TestClass(){i++;} ~TestClass(){i--;} static int getVal(){return i;} }; int TestClass::i=0; void f(){TestClass obj2;cout<<obj2.getVal();} int main(){ TestClass obj 1; f(); TestClass *obj3=new TestClass;cout<<obj3->getVal(); delete obj3;cout<<TestClass::getVal(); return 0; } 程序的输出结果是( )。
转载请注明原文地址:https://www.kaotiyun.com/show/AJVp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列叙述中,不属于设计准则的是()。
C语言中规定,程序中各函数之间()。
若有定义:inta;floatb;doublec;,程序运行时输入:a=1,b=2,c=3,能把值1输入给变量a、值2输入给变量b、值3输入给变量c的输入语句是()。
有以下程序:#includemain(){unsignedchara=2,b=4,c=5,d;d=aIb;d&=c;printf("%d\n",d;}程序运行后的输出结果是(
假定输入的字符串中只包含字母和*号。请编写函数fun,它的功能是:使字符串中尾部的*号不得多于n个;若多于n个,则删除多余的*号;若少于或等于n个,则什么也不做,字符串中间和前面的*号不删除。例如,字符串中的内容为:****A*BC*DEF*G*
在数据库设计中,将E-R图转换成关系数据模型的过程属于()。
设有定义:doublea[10],*s=a;,以下能够代表数组元素a[3]的是()。
下列工具中,不属于结构化分析的常用工具的是()。
关于计算机算法的时间复杂度的叙述中正确的是()。
结构化程序设计的基本原则不包括( )。
随机试题
Theadvertisementforthesecurityguardpositionsaysthatapplicantsmustbeabletoremain________forsixhoursstraight.
齿轮传动常见故障有哪些?
下列各项属于生态环境现状调查与评价中自然环境调查内容的有()。
车站的调车工作由()统一领导。
对应收账款进行清查时,应采用的方法是()。
下列车辆中,纳税人出具有效证明后,即以统一发票或有效凭证注明的计税价格作为车辆购置税计税依据的有()。
要求企业的经营要素在有机组合中能发挥回避和减弱乃至消除风险的作用的是()。
应收票据在贴现时,其贴现息应该记入的科目是()。
ThereisnowanewkeychaindevicethatletspeopleturnoffmostTVsanywhere—fromairportstorestaurants.Anditissellingf
TherearemorethanfortyuniversitiesinBritain--nearlytwiceasmanyasin1960.Duringthe1960seight【67】newoneswerefoun
最新回复
(
0
)