首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
若有如下程序: #include using namespace std; hat s=0; class sample { static im n; public: sample(int i)
若有如下程序: #include using namespace std; hat s=0; class sample { static im n; public: sample(int i)
admin
2021-05-06
53
问题
若有如下程序:
#include
using namespace std;
hat s=0;
class sample
{
static im n;
public:
sample(int i)
{
n=i;
}
static void add()
{
s+=n;
}
};
int sample::n=0;
intmain0
{
s
选项
A、2
B、5
C、7
D、3
答案
B
解析
执行语句“sample a(2),b(5)”;的结果是使n的值最终变为5,sample::add()语句调用函数staticvoid add,(),使得S=S+n=5。
转载请注明原文地址:https://kaotiyun.com/show/MHfp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列关于运算符重载的叙述中,错误的是()。
有如下程序:#include<iostream>usingnamespacestd;classMyClass{public:MyClass(){++count;}~MyClass(){--c
下列关于析构函数的描述中,错误的是()。
有如下程序#include<iostream>iasingnamespacestd;classTest{public:Test(){}Test(constTest&t){cout<<1;
下列代码段中声明了3个类:classPerson}};classStudent:publicPerson{};classUndergraduate:Student{};下列关于这些类之闻关系的描述中,错误的是
下列各组类型声明符中,含义相同的一组是()。
有如下类和对象的定义:classConstants{public;staticdoublegetPl0{retum3.1416;});Constantsconstants;下列各组语句中
深度为7的完全二叉树中共有125个结点,则该完全二叉树中的叶子结点数为
下列符号中,正确的C++标识符是()。
随机试题
在8086CPU中,用于存放代码段的段地址的寄存器是()
A.胃脘隐痛B.胃脘刺痛C.胃脘胀痛D.胃脘灼痛肝胃郁热之胃痛可见()
在建设单位的计划体系中,工程项目建设总进度计划不包括()。
对广东省东莞市人民政府作出的具体行政行为不服申请复议的,由()管辖。
令人奇怪的是,洛可可风格竟然首先出现于法兰西。路易十四的统治持续时间太长,对老王朝过分虔诚的时代终于结束,雄伟高贵的凡尔赛不再迫使人们参加令人生厌的庆典,从此人们聚集于巴黎各公馆的精美沙龙之中。起初,洛可可是一种新型装饰,是为热爱冒险、异国情调、奇思遐想和
下列不属于其他业务成本核算内容的项目是()。
ItwasinevitablethatanyofPresidentGeorgeW.Bush’sfanshadtobeverydisappointedbyhisdecisiontoimplementhightari
ISP是掌握Internet______的机构。
Nowadaysthescatteringofgalaxiesandtheastoundingabundanceofstarsareforcingthosewhopondersuchmatterstoafurther
Themainpurposeofthispassageisto______.Accordingtotheauthor,itisimpossibleatpresenttocut60%ofcarbondioxide
最新回复
(
0
)