首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
2021-06-10
28
问题
有如下程序:
#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/Xcfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#include<iostream>usingnamespacestd;classPair{intm;intn;public:Pair(inti,intj):m(i),n(j){}booloperator>(Pa
有如下类定义:classPoint{private;staticinthow_many;};________how_many=0;要初始化Point类的静态成员howmany,下划线处
使用VC6打开考生文件夹下的源程序文件modi3.cpp,其中定义了用于表示日期的类Date,但类Date的定义并不完整,按要求完成下列操作,将类的定义补充完整。(1)定义私有成员变量year、month、day,分别表示年、月、目,类型为int。请在注
请使用VC6或使用【答题】菜单打开考生目录proj3下的工程文件proj3,此工程中包含一个源程序文件proj3.cpp,其功能是从文本文件in.dat中读取全部整数,将整数序列存放到intAn’ay类的对象中,然后建立另一对象myArray,将对象内容赋
下列语句都是程序运行时的第1条输出语句,其中一条语句的输出效果与其他三条语句不同,该语句是()。
数据流图中带有箭头的线段表示的是( )。
在关系数据库中,用来表示实体间联系的是
下列选项中,不是C++关键字的是()。
下面属于黑盒测试方法的是
数据结构主要研究的是数据的逻辑结构、数据的运算和()。
随机试题
下列属于公务员不可放弃的权利是
二氯三氟乙烷CHCl2CF2的制冷剂代号是_______。
图示梁EI=常数,B端的转角是:
其他合作机构风险的防控措施包括()。
下列选项中,针对产品大类描述正确的是()。
我国国家领导人连续任职不得超过两届的有()。
APayRiseorNot?"UnlessIgetarise,I’llhaveatalkwiththeboss,HenryManley,"GeorgeStrongsaidtohimself.George
AwarmthoughtsuddenlyAcametomeBwhichImightCusethepocketmoneytobuysomeflowersDformymother’sbirthday.
Whattopicarethemanandwomandiscussing?
ShoppinghabitsintheUnitedStateshavechangedgreatlyinthelastquarterofthe20thcentury.【C1】______inthe1900smost
最新回复
(
0
)