首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
根据输出结果填空完成下面程序。 # include<iostream. h> class Test { private: static int val; int a; public:
根据输出结果填空完成下面程序。 # include<iostream. h> class Test { private: static int val; int a; public:
admin
2010-06-06
23
问题
根据输出结果填空完成下面程序。
# include<iostream. h>
class Test
{
private:
static int val;
int a;
public:
static int func( );
void sfunc(Test &r);
};
【 】//初始化静态变量val
int Test::func()
{
return val++;
}
void Test::sfunc(Test &r)
r. a=125;
cout<<"Result3="<<r.a;
}
void main( )
{
cout<<"Resultl="<<Test::func( )<<endl;
Test a;
cout<<"Result2="<<a. func( );
a. sfunc(a)
}
选项
答案
int Test::val=200;
解析
类的静态成员变量必须要进行初始化才能使用,初始化时需要用域限定符::指明该变量所属的类名。
转载请注明原文地址:https://jikaoti.com/ti/SwW0FFFM
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
以下选项中不合法的标识符是( )。
有以下程序#include<stdio.h>main(){inty=10;while(y--);printf("y=%d\n",y);}程序执行后的输出结果是
有以下程序:#include<stdio.h>main(){inty=10;while(y--);printf("y=%d\n",y);}程序执行后的输出结果是()。
C语言程序的模块化通过以下哪个选项来实现()。
下列给定程序中函数fun的功能是:用冒泡法对6个字符串进行升序排列。请改正程序中的错误,使它能得出正确的结果。注意:部分源程序在文件MOD11.C中,不得增行或删行,也不得更改程序的结构!#include#include#defineM
以下有关宏的描述不正确的是()。
以下关于结构化程序设计的叙述中正确的是()。
对序线性表(23,29,34,55,60,70,78)用二分法查找值为60的元素时,需要比较次数为()。
已知二叉树后序遍历序列是CDABE,中序遍历序列是CADEB,它的前序遍历序列是()。
给定程序MODI1.C中的函数Creatlink的功能是创建带头结点的单向链表,并为各结点数据域赋0到m-1的值。请改正函数Creatlink中指定部位的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改
随机试题
患者,女,34岁,双上臂外侧对称出现约5cm×10cm的皮损,皮色潮红,有丘疱疹,灼热瘙痒无休止,抓破渗液流脂水;伴心烦口渴、身热不扬、大便干、小便短赤;舌红、苔薄白或黄,脉滑数。治宜选用
A.生津安蛔B.敛肺滋肾C.温中止痛D.收敛止血E.涩肠温中
央行不能通过增加或减少货币供应量调节货币市场,实现对经济的干预。()
下列选项中,属于申请上市的基金必须符合的条件是()。
(2017年临沂)定势只会减慢问题解决的速度,不会提高问题解决的效率和质量。
一种学习中习得的一般原理、方法、策略和态度等迁移到另一种学习中去是()。
2009年罗马游泳世锦赛尘埃落定,高科技泳衣成为了本届世锦赛的焦点话题,以至于比赛本身反而被忽略了。可实际上,泳衣问题并不是2009年才出现的,只不过Speedo的垄断格局被颠覆,或者说聚亚氨酯材料被竞争对手Jaked01和ArenaX-Glide引进,
执行下列语句段后,输出字符"*"的个数是()。for(inti=50;i>1;i-=2)cout
为考生文件夹下WALL文件夹中的PBOB.TXT文件建立名为KPBOB的快捷方式,并存放在考生文件夹下。
线条
最新回复
(
0
)