首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
根据输出结果填空完成下面程序。 #include<iostream.h> class Test { private: static int val; int a; public: st
根据输出结果填空完成下面程序。 #include<iostream.h> class Test { private: static int val; int a; public: st
admin
2010-12-16
19
问题
根据输出结果填空完成下面程序。
#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.fune( )<<endl;
A. sfunc(A);
}
输出结果为:
Result1=201
Result2=202
Result3=125
选项
答案
int Test::val=200;
解析
类的静态成员变量必须要进行初始化才能使用,初始化时需要用域限定符::指明该变量所属的类名。
转载请注明原文地址:https://kaotiyun.com/show/N9Vp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
读取二进制文件的函数调用形式为:fread(buffer,size,count,fp);,其中buffer代表的是()。
在黑盒测试方法中,设计测试用例的主要根据是()。
有以下程序:#include<stdio.h>main(){intx=1,y=0,a=0,b=0;switch(x){case1:switch(y){case0:a++;break;case1:b++;break;}case2:a++
语句“printf("a\bhow\’are\’y\\\bou\n");”的输出结果是()。
有以下函数:intltaa(char*s){char*t=s;while(*t++);t一一;return(t—s);}以下关于aaa函数功能叙述正确的是()。
若a、b、c、d都是int型变量且都已经正确赋初值,则以下不正确的赋值语句是()。
下列叙述中正确的是()。
以下选项中,不能对主函数中变量i和j的值进行交换的程序是()。
在结构化方法中,用数据流程图(DFD)作为描述工具的软件开发阶段是
成本效益分析的目的是从【】角度评价开发一个项目是否可行。
随机试题
图中警察手势为直行信号。
______是无产阶级的第一个政治纲领。
女,55岁。腹痛3天,恶心、呕吐,不排便。查体:肥胖,右侧腹股沟区较左侧饱满伴压痛。腹部透视见腹部胀气有数个液平段。诊断应首先考虑
A.与成年人极轻体力劳动者相当 B.与成年人轻体力劳动者相当 C.与成年人中体力劳动者相当 D.与成年人重体力劳动者相当 E.16736~18828kJ(4000kcal~4500kcal)为宜建议飞行员的平均能量摄入量应为
男性,23岁,突起右下腹痛,短时间便觉全腹痛,半个月前曾有过“感冒”,表现发热、头痛、四肢酸痛、食欲不振,在当地医院门诊按“上感”服药治疗过。查体:全腹压痛及反跳痛,肠鸣音消失。上述病例如经非手术治疗好转,1周后突然腹痛而出现腹膜炎,施行剖腹探查术中见
甲企业为增值税一般纳税人,2015年2月购进一批货物,取得普通发票上注明金额3510元;当月零售10箱货物给消费者个人,取得不含税销售额为15000元;当月将外购的20箱同类货物投资到乙企业。已知该货物适用的增值税税率为17%,则下列关于甲企业的相关税务处
[*]
微分方程y″-2yˊ+y=ex的特解形式为()
JeanWagner’smostenduringcontributiontothestudyofAfro-Americanpoetryishisinsistencethatit______inareligious,a
A、Itwouldforcepoorpeopletochangetheirdiet.B、Itwouldneedsupportfromthegeneralpublic.C、Itwouldgeneratemoneyfo
最新回复
(
0
)