首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Test { public: Test() {n+=2;} ~Test() {n-=3;}
有如下程序: #include using namespace std; class Test { public: Test() {n+=2;} ~Test() {n-=3;}
admin
2015-09-14
11
问题
有如下程序:
#include
using namespace std;
class Test
{
public:
Test() {n+=2;}
~Test() {n-=3;}
static hat getNum(){return n;}
private:
static int n;
};
hatTest::n=1;
int main()
{
Test
*
p=newTest;
delete p;
cout<<"n="<
return 0;
}
执行后的输出结果是( )。
选项
A、n=0
B、n=1
C、n=2
D、n=3
答案
A
解析
此题考查的是静态数据成员和静态成员函数。静态数据成员是类中所有对象共享的成员,而不是某个对象的成员。题目中的静态数据成员n的运算具有叠加性,执行“n+=2”和“n-=3”后n的值为0。
转载请注明原文地址:https://kaotiyun.com/show/pqNp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
在结构化分析方法中,用于描述系统中所用到的全部数据和文件的文档称为【】。
设有程序段intk=10;while(k=0)k=k-1;则下面描述中正确的是
下面程序的预设功能是:统计文件abc.txt中的字符个数。#include<iostream.h>#include<fstream.h>#include<stdlib.h>voidmain(){
下列叙述中正确的是
软件工程包括3个要素,分别为方法、工具和【】。
C++语言中关键字运算符有new,delete和______。
下列不属于结构化分析的常用工具的是
数据管理技术的发展是与计算机技术及其应用的发展联系在一起的,经历了由低级到高级的发展过程。分布式数据库、面向对象数据库等新型数据库是属于()。
下列运算符中,()运算符不能在C++中重载。
多态性分为两类:编译时的多态性和【】。
随机试题
小便不甚赤涩,但淋漓不已,时作时止,遇劳即发,腰膝酸软,神疲乏力,病程缠绵,舌质淡,脉细弱,宜选方
A、乳汁管B、油室C、油管D、油细胞E、树脂道防风有()
红黏土的矿物成分主要是()。
根据港口工程特点,对不计波浪力的建筑物在验算地基竖向承载力时,其水位采用( )。
收入型证券组合追求基本收益的最大化,主要投资于()。
政府预算草案编制完成以后,只有经过()审查和批准后,才能成为政府预算,才能成为具有法律意义的文件。
跳跃:动作
基层人民法院可以管辖()第一审行政案件。
商业广告是指商品经营者或者服务提供者承担费用,通过一定的媒介和形式直接或间接地介绍自己所推销的商品或者所提供的服务。下列属于商业广告的是()。
StratonLifeAssuranceNewEmployeeTrainingTheme:NewBeginnings,NewChallenges*Pleasedonotforgettowriteareportto
最新回复
(
0
)