首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; class Point{ public: static int number; public: Point
有如下程序: #include<iostream> using namespace std; class Point{ public: static int number; public: Point
admin
2020-07-23
68
问题
有如下程序:
#include<iostream>
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∷number<<end1:
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/thyp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#includeusingnamespacestd;classXA{inta;public:s
有如下类定义:classFoo{public:Foo(intv):value(v){} //①~Foo(){} //②private:Foo(){}
下列有关类继承的叙述中,错误的是()。
将E-R图转换为关系模式时,实体和联系都可以表示为( )。
下列有关虚函数的表述中正确的是
下面属于黑盒测试方法的是
已知函数f的原型是voidf(int*a,long&b);,变量v1、v2的定义是:intv1;longv2;下列调用语句中正确的是()。
下列哪项不是面向对象程序设计的主要特征()。
下列数据结构中,能用二分法进行查找的是()。
以下数据结构中,属于非线性数据结构的是()。
随机试题
拥有地方立法权的有()
Webtechnology
下列贫血性疾病中,最易见嗜多色性红细胞、点彩红细胞、Howell-Jolly小体和Cahot环的是
某建筑面积为44000m2的地下商场,采用防火分隔措施将商场分隔为多个建筑面积不大于20000m2的区域。该商场对区域之间局部需要联通的部位采取的防火分隔措施中,符合现行国家标准《建筑设计防火规范》(GB50016)的是()。
下列交易或事项能够增加企业所有者权益的是()。
关于等距抽样,下列说法不正确的是()。
3岁前儿童的思维基本上属于哪种思维的范畴?()
Manycriticsconsiderthatfarmorestressisplacedonachievementsinathleticsthanintheacademicsphere.We’retoldthati
A、$5.B、$15.C、$5.20.D、$5.12.CHowmuchshouldthecustomerpayforthegloves?
Bloggingisapastimeformany,evenalivelihoodforafew.Forsome,itbecomesan【36】Suchbloggersoftenfeelcompelledtowr
最新回复
(
0
)