首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有下列程序: #include<iostream> using namespace std; classTest{ public: Test() {n+=2;} ~Test() {n-=3;} s
有下列程序: #include<iostream> using namespace std; classTest{ public: Test() {n+=2;} ~Test() {n-=3;} s
admin
2010-12-16
38
问题
有下列程序: #include<iostream> using namespace std; classTest{ public: Test() {n+=2;} ~Test() {n-=3;} static int getNum(){return n;} private: static int n; }; int Test::n=1; int main() { Test*p=new Test
选项
A、n=0
B、n=l
C、n=2
D、n=3
答案
A
解析
语句Test*p=new Test;会调用类的构造函数Test() {n+=2;},使n的值由原来的1变为3,然后delete p调用类的析构函数~Test() {n-=3;},因为n是static型变量,所以会在3的基础上减3使得输出结果为0。
转载请注明原文地址:https://jikaoti.com/ti/4rL0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有以下程序:#includeintfun(int(*s)[4],intn,intk){intm,i;m=s[0][k];for(i=1;im)m=s[i][k];return
有以下程序#include<stdio.h>#include<string.h>typedefstruct{charname[10];charsex;
若有以下函数首部:intfun(doublex[10],int*n)则下面针对此函数的函数声明语句中正确的是()。
可在C程序中用作用户标识符的一组标识符是()。
给定程序中,函数fun的功能是:将参数给定的字符串、整数、浮点数写到文本文件中,再用字符串方式从此文本文件中逐个读入,并调用库函数atoi和atof将字符串转换成相应的整数、浮点数,然后将其显示在屏幕上。请在程序的下画线处填入正确的内容并把下画线删除,使
在长度为n的有序线性表中进行二分查找,最坏情况下需要比较的次数是()。
已知一个文件中存放若干工人档案记录,其数据结构如下:structa{charnumber[100];intage;floatp[6];};定义一个数组:structab[10];假定文件己正确打开,不能正确地从文件中读入10名工人
以下不属于结构化程序设计原则的是()。
重载的流运算符函数应该被定义为类的【】函数。
在一个C++程序中,每个变量都必须遵循【】的原则。
随机试题
电动压力调节器开度突然变大的原因可能是()。
有"夏月之麻黄"之称的药物是
骨折近端向后倾斜移位骨折远端向后倾斜移位
慢性呼吸衰竭最常见的酸碱失衡是
对建筑物的基本要求是安全、适用、经济、美观,下列对建筑物的要求中,属于适用方面的要求是()。
由于职业判断贯穿于注册会计师审计工作的全过程,并且可能得到的审计证据有很多是说服性而非结论性的,因此,注册会计师的任何审计意见都不能绝对保证会计报表使用人确定已审计会计报表的可靠程度。 ( )
简要回答幼儿成长档案袋评价的含义及基本内容。
行政主体就是行政法律关系主体。()
某温泉旅游胜地村委会主任选举时,温泉度假村总经理姜某许诺给他投票的选民可以获赠温泉度假村门票10张,并为谋求镇政府支持送给镇长温泉度假村VIP钻石卡一张(价值10万元)。对于姜某的行为说法正确的是()
2017年11月25日,甲(2003年11月26日出生)在公共汽车上将手伸进丙的衣袋偷东西,丙发现后立即抓住甲的手。甲的同伙乙(2000年12月5日出生)见状拔出甲随身携带的匕首刺向丙胸部。丙情急之下拉过乘客陈某的胳膊挡在自己前面,乙刺中陈某胳膊,致其轻伤
最新回复
(
0
)