首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: 衔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
35
问题
有如下程序:
衔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>#include<fstream,h>voidmain(){fstreamfilel,file2
在数据流图(DFD)中,带有名字的箭头表示
下列程序的运行结果是【 】。#include<iostream.h>#include<string.h>voidmain(){char*a[5]={"stuent","worker","tea
执行语句序列charstrl[10]="ABCD",str2[10]="XYZxyz";for(inti=0;strl[i]=str2[i];i++)后,数组str1中的字符是XYZxyz,数组str2中的字符串是【 】。
下面程序的运行结果为( )。 class A{ static int n; public: A(){n=1;} A(int num){n=num;} vo
含有纯虚函数的类称为【】。
有如下数组声明:intvalue[30];下标值引用错误的是()。
下面关于对象概念的描述中错误的是()。
执行下列语句后,输出结果为cout. put(’s’);cout<<,’c’<<’a’;
在下面的运算符重载函数的原型中,错误的是
随机试题
唐朝不适用“同居相隐不为罪”原则的罪名有()
《光的赞歌》作者_________,是中国现代诗的代表诗人之一,主要作品有《_________——我的保姆》。
试述深Ⅱ°烧伤临床特点。
下列哪项是慢性支气管炎的临床分型
当工程质量事故处理完毕进行鉴定验收时,监理工程师应()。
对于选中的文件,可以实现删除操作的是()。
以下饭店,位于外滩聚集区的有()。
在国家政权中,军队与警察是最主要的支柱。()
下列哪一项不符合腺泡中央型肺气肿
Thereisplentyofcomplaintsabouthowsocialmedia—textinginparticular—maybeharmingchildren’ssocialandintellectualdev
最新回复
(
0
)