首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #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
2019-08-23
65
问题
有如下程序:
#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/vD8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列程序的输出结果是#inClUde<iostream>usingnamespacestd;intmain(){Chara[]="HellO,World";Char*ptr=a;while(
关于构造函数A()的拷贝构造函数正确的是
运算符“+”允许重载为类成员函数,或者非成员函数。若用operator+(c1,c2)这样的表达式来使用运算符“+”,应将“+”重载为【】函数。
在一个派生类对象结束其生命周期时()。
在C++语言的数据类型中,int、short等类型的长度是()。
派生类的构造函数的成员初始化列表中,不能包含
有如下函数模板:template<typenameT,typenaineU>Tcast(Uu){returnu;}其功能是将U类型数据转换为T类型数据。已知i为int型变量,下列对模板函数cast的调用中正确的是
在数据库系统中,用户所见的数据模式为
在最坏情况下,冒泡排序的时间复杂度为______。
算法的时间复杂度是指()。
随机试题
简述组织行为学应用性的主要表现。
“一国两制”构想的提出最初是为了解决( )。
Helikedthepaintingverymuch,whichcosthim$1,000.However,hewouldgladlyhavepaid______forit.
与参苓白术散主治病证病机无关的是
治疗亡阳虚脱及中脏寒盛者均可以用的药组是
汗证表虚不固证的治法是汗证气阴虚弱证的治法是
再生障碍性贫血诊断依据中错误的是
财产损失险主要分为()。
IhavebeenveryluckytohavewontheNobelPrizetwice,Itis,ofcourse,veryexcitingtohavesuchanimportant【C1】______of
数据库设计的四个阶段是:需求分析、概念设计、逻辑设计和()。
最新回复
(
0
)