首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
69
问题
有如下程序:
#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://www.kaotiyun.com/show/E0fp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
派生类的对象对它的基类成员中()是可以访问的。
下列叙述中正确的是()。
有如下程序:#includeusingnamespacestd;classB{public:B(intxx):x(xx){++count;x+=10;}virtualvoids
有如下程序:#include<iostream>usingnamespacestd;classPair{intm;intn;public:Pair(inti,intj):m(i),n(j){}booloperator>(Pa
若有下面的函数调用:fun(a+b,3,max(n-1,b))则fun的实参个数是()。
以下数据结构中,属于非线性数据结构的是()。
执行下列语句段后,输出字符“*”的个数是()。for(inti=50;i>1;I-=2)cout
下列关于this指针的叙述中,正确的是()。
下列字符串中可以用作C++标识符的是
随机试题
使用VC6打开考生文件夹下的源程序文件modi3.cpp,其中定义了用于表示日期的类Date,但类Date的定义并不完整,按要求完成下列操作,将类的定义补充完整。(1)定义私有成员变量year、month、day,分别表示年、月、日,类型为int。请在注
下列关于赠与合同的约定,说法正确的是:()
八正散与小蓟饮子组成中均含有的药物是
肌壁间肌瘤的临床表现,下列哪项是错误的
有关法与科技的说法中,下列哪一选项是错误的?()
下列免征城镇土地使用税的有()。
根据下列资料。回答下列问题。进入2012年以来,一些企业开始审慎评估之前的并购效果以及新的并购机会,海外并购开始趋于理性化、审慎化。2005年中国企业海外并购事件开始发生,2008年并购进入活跃阶段。从有关资料了解到,2005—2012年,
Likemanyofmygeneration,Ihaveaweaknessforheroworship.Atsomepoint,however,wealltoquestionourheroesandourne
CPU暂停现行程序而转去响应中断请求的过程称为______。
Weenjoyfinefoodfromthefirsttastetothelast.Similarly,goodwritingissomethingwe【C1】______withpleasure.Andgoodw
最新回复
(
0
)