首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Point{ public: static int number; public: Point(){number++;
有如下程序: #include using namespace std; class Point{ public: static int number; public: Point(){number++;
admin
2020-12-21
59
问题
有如下程序:
#include
using namespace std;
class Point{
public:
static int number;
public:
Point(){number++;}
~Point(){number--;}
};
int Point::number=0:
int main(){
Point*ptr;
Point A,B;
{
Point*ptr_point=new Point[3];
ptr=ptr_point;
}
Point C:
cout<<Point::numbe<<endl;
delete[]ptr;
return0;
}
执行这个程序的输出结果是( )。
选项
A、3
B、4
C、6
D、7
答案
C
解析
本题考查默认构造函数,题目中定义一个对象A、B以及对象数组Point[3],又定义了对象C,共执行6次构造函数,number变为了6,所以本题答案为C。
转载请注明原文地址:https://kaotiyun.com/show/6pyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
在声明派生类时,如果不显示地给出继承方式,缺省的类继承方式是私有继承private。己知有如下类定义:classTestClass{protected:voidfun(){}};classTestCl
有如下程序:#includeusingnamespacestd;classA{public:A(){cout
下面程序的输出结果是()。#include#includeusingnamespacestd;classpoint{private:doublex:double
下列关于this指针的叙述中,正确的是()。
有如下程序段int i=0,j=1;int &r=i; //①r=j; //②int*p=&i; //③*p=&r; //④其中会产生编译错误的语句是
在C++中用来实现运行时多态性的是
如果不使用多态机制,那么通过基类的指针虽然可以指向派生类对象,但是只能访问从基类继承的成员。有如下程序,没有使用多态机制。#include<iostream>using namespace std;class Base{ int a,b;public
在数据库设计中,将E-R图转换成关系数据模型的过程属于
设某棵树的度为3,其中度为3、1、0的结点个数分别为3、4、15。则该树中总结点数为
随机试题
李某自2007年4月起开始非法制造、贩卖匕首,至次年1月停止。2008年8月公安机关根据举报发现了李某的违法行为。下列哪一种说法是正确的?()
根据我国物权法的规定,土地承包经营权的取得时间是
国家主席习主席2月13日在人民大会堂会见匈牙利总理欧尔班时表示,两国建交来,双边关系基础始终牢固,合作一直良好。()
Inrecentyears,moreandmoreforeignersareinvolvedintheteachingprogramsoftheUnitedStates.Boththeadvantagesandth
《风波》的时代意义在于()
在对会计凭证进行保管时,应该注意的地方有()。
WhichonedoesnotbelongtotheBronteSister’sworks?
A、B两山村之间的路不是上坡就是下坡,相距60千米。邮递员骑车从A村到B村,用了3.5小时;再沿原路返回,用了4.5小时。已知上坡时邮递员车速是12千米/小时,则下坡时邮递员的车速是()。
在操作系统中,对信号量S的P原语操作定义中,使进程进入相应等待队列等待的条件是(41)。
Doctorssayangercanbeanextremelydamagingemotionunlessyoulearnhowtodealwithit.Theywarnthatangryfeelingscan【
最新回复
(
0
)