首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Point{ public: static int number; public: Pointo{numb
有如下程序: #include using namespace std; class Point{ public: static int number; public: Pointo{numb
admin
2020-07-30
111
问题
有如下程序:
#include
using namespace std;
class Point{
public:
static int number;
public:
Pointo{number++;}
~Point(){number--;}
};
int Point∷number--0:
void mainO{
Point
*
ptr;
PointA,B;
{
Point
*
ptr_point=new Point[3];
ptx=ptr_point;
}
Point C:
Gout+Point∷number+end1;
delete[]ptr;
}
运行时输出的结果是( )。
选项
A、3
B、4
C、6
D、7
答案
C
解析
此题是静态成员、对象的构造和对象的生存期等知识点的综合考查。此题定义了一个静态成员变量number,初始值为0。主函数中第2行定义了2个Point对象,此时nunlber变为2;随后new运算符又定义了一个包含3个Point对象元素的数组,其通过delete结束后number的值变为5;然后又定义了一个Point对象C,number变为6;最后输出number的内容。
转载请注明原文地址:https://kaotiyun.com/show/aUyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
已知数组arr的定义如下:intarr[5]={1,2,3,4,5};下列语句中输出结果不是5的是
下列关于虚基类的描述,错误的是()。
有如下函数模板定义:templateT1FUN(T2n){returnn*5.0;}若要求以int型数据9作为函数实参调用该模板,并返回一个double型数据,则该调用应表示为
下列选项中,正确的C++表达式是
在数据库中,数据模型包括数据结构、数据操作和
下面对类-对象主要特征描述正确的是
下列关于函数参数的叙述中,正确的是
有三个关系R、S和T如下:则由关系R和S得到关系T的操作是()。
关于new运算符的下列描述中,错误的是()。
若整型变量a、b、e、d中的值依次为:1、4、3、2.则条件表达式a<b?a:e<d?c:d的值是()。
随机试题
Manisendlesslyinventive.Buthisgreatestinventionisnon-invention,theskilloftransmittingintact(完美无损的)andunchangedfrom
下列影响股票投资价值的外部因素中,不属于宏观经济因素的是()。
在计算速动比率时,要从流动资产中扣除存货部分,再除以流动负债,这样做的原因是流动资产中()。
()是导游人员对待游客的个别要求和提供个性化服务应遵循的原则。
Inthefollowingtext,somesentenceshavebeenremoved.ForQuestions41-45,choosethemostsuitableonefromthelist(A、B、C、
在C语言中,只有在使用时才占用内存单元的变量,其存储类型是()。
Thesteadyhumofschoolheatingsystemsandair-conditionerscanmeanlowertestscoresformanyyoungstudents,foundanewst
FamousChristmasPlacesTherearemany【T1】______traditionsinChristmas.【T1】______ThetwofamousChristmasplacesare:1.Mid
Theold-fashionedgeneralstoreisfastdisappearing.Thisis,perhaps,apity,becauseshoppingtodayseemstolackthatperson
Yourweightaffectshowlongyoulive—butit’sextremelycomplicatedA)Weoftenthinkaboutweightlossintheshortterm,h
最新回复
(
0
)