首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include using namespace std; class Point { public: static int number; public: Point() { number++; } ~Point() { number-
有如下程序: #include using namespace std; class Point { public: static int number; public: Point() { number++; } ~Point() { number-
admin
2021-06-10
21
问题
有如下程序:
#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<
delete[] ptr;
return 0;
}
执行这个程序的输出结果是( )。
选项
A、3
B、4
C、6
D、7
答案
C
解析
本题考查默认构造函数,题目中定义一个对象A、B以及对象数组Point[3],又定义了对象C,共执行6次构造函数,number变为了6,所以本题答案为C。
转载请注明原文地址:https://kaotiyun.com/show/E0fp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
若一个函数的原型为“int木*fiml(intx,int&Y,charz);”,则该函数的返回值类型为()。
有如下程序:#includeusingnamespacestd;classGA{public;virtualintf0{return1;}};classGB:public
以下程序输出结果是():#include<iostream>usingnamespacestd;voidadd(intx,inty,int*z){*Z=y+x;}intmain()
有如下头文件:intfl();staticintf2();classMA{public:intf3();staticintf();};在所描述
一棵二叉树共有25个结点,其中5个是叶子结点,则度为1的结点数为
对长度为10的线性表进行冒泡排序,最坏情况下需要比较的次数为()。
下列叙述中正确的是
下列关于类模板的表述中,错误的是
除了显式定义的构造函数外,类中还有可能包含编译器自动生成的构造函数,因此一个类所拥有的构造函数的至少有
关于关键字class和typename,下列表述中正确的是()。
随机试题
义务教育经费严格按照预算规定用于义务教育;任何组织和个人不得侵占、挪用义务教育经费,不得向学校非法收取或者摊派费用。()
什么是冷焊法?
Itseemssonaturaltoputupanumbrellatokeepthewateroffwhenitrains.Butactuallytheumbrellawasnotinventedaspro
治疗急性梗阻性化脓性胆管炎最常用的有效手术方式是
在功能的系统分析过程中,()工作可以更准确地选择价值工程研究对象,同时,制定目标成本,有利于提高价值工程的工作效率,并增加工作人员的信心。
证券金融公司向证券公司转融通的期限一般不得超过()个月。
根据公司法律制度的规定,有限责任公司的股东转让股权后公司无须办理的事项是()。
甲企业采用移动加权平均法计算发出甲材料的成本,2013年4月1日,甲材料结存300千克,每千克实际成本为3元;4月3日,发出甲材料100千克;4月12日,购入甲材料200千克,每千克实际成本10元;4月27日,发出甲材料350千克,4月末该企业甲材料的期末
SharingSilenceDeafteenagersOrlandoChavezandGermanResendizhavebeenfriendssincekindergarten(幼儿园).Togetherthet
Ialwayseatbreakfast,andsuggestthatyoudotoo.Weallneedfoodinthemorningtosupplyourselves【C1】______sourcesofgl
最新回复
(
0
)