首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: 衔nclude<iostream> using namespace std; class Point{ public: static int number; public: Point(
有如下程序: 衔nclude<iostream> using namespace std; class Point{ public: static int number; public: Point(
admin
2017-07-05
32
问题
有如下程序:
衔nclude<iostream>
using namespace std;
class Point{
public:
static int number;
public:
Point(){number++;}
~Point(){number一一;}
};
int P0int::"number=0;
int main(){
Point*ptr;
P0int A,B;
{
Point*ptr_point=Hew Point[3];
ptr=ptr_point;
}
Point C;
cout<<Point::number<<endl;
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/qLAp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列程序执行结果是 #include <iostream.h> class A { public: int a; A():a(10){cout<<a<<endl;} }; void main()
以下程序的输出结果是 main() {int a=4,b=5,c=0,d; d=! a&&! b||! c; cout<<d<<cndl; }
数据的独立性是数据库技术的重要特点之一。所谓数据独立性是指
下列程序对加号进行了重载,划线部分的语句是【 】。#include<iostream.h>#include<math.h>classTriangle{intx,y,z;double
下面程序的运行结果是( )。 #include <iostream> using namespace std; template <class T> class A{ T x,y; public:
对于下面程序,对p调用正确的是( )。 class A{ public:fun(int i){cout<<i<<endl;} }; main(){ A a; int k=0; void(A
数据库设计包括两个方面的设计内容,它们是()。
设有n元关系R及m元关系S,它们分别有p、q个元组,则关系R与S经笛卡尔积记为R×S,该关系是一个n+m元关系,那么其元组个数是()。
下列关于线性表叙述中,不正确的是()。
下列符号中可以用作C++标识符的是()。
随机试题
概述汉代从“黄老之学”到“霸王道杂之”的思想演变。(首都师范大学2013年历史学基础真题)
在进行网上交易时,信用卡的账号和用户名、证件号码等被他人知晓,这是破坏了信息的是_______。
5个月小儿一直牛乳喂养,检查发现血清铁蛋白下降。另一名同龄小儿一直母乳喂养则无此改变,原因是
土工合成材料常规厚度是在()压力下的厚度测定值。
如图7-78所示,金属导轨上放置着ab和cd两根金属棒,各长1m,电阻均为4Ω,均匀磁场B=2T,方向垂直向里,当ab以v1=4m/s,cd以v2=2m/s的速度向左运动时,a、b两点间的电压Uab=()V。(忽略导轨电阻)
软盘在读写时不能取出,否则可能会损伤磁盘。()
中共第一次明确提出“使马克思主义中国化”的命题和任务的会议是
下列程序段运行结束后,变量x的值是()。x=2Y=2Dox=x*yy=y+1LoopWhiley<4
SpeakerA:Oh,doesn’tyourdaughterlooklovely?SpeakerB:______
【B1】______TheInternet,whichmeansinterconnectednetworkofnetworks,linkstensofthousandsofsmallercomputernetworks.Th
最新回复
(
0
)