计算机二级考试

解析:有如下程序: #include<iostream> using nam

来源:网考网计算机二级 所有评论

【单选题】有如下程序:
#include<iostream>
using namespaee std;
int i=1;
class Fun
public:
static int i;
int value( )
return i-1;
int value( )cons[
return i+1;

int Fun::i=2;
int main( )
int i=3;
Fun funl;
const Fun fun2;
______:
return 0;
若程序的输出结果是:
123
则程序中下画线处遗漏的语句是
A、cout<<funl.value( )<<Fun::i<<fun2.value( );
B、cout<<Fun::i<<funl.value( )<<fun2.value( );
C、cout<<funl.value( )<<fun2.value( )<<Fun::i;
D、cout<<fun2.value( )<<Fun::i<<funl.value( );

网考网参考答案:A
网考网解析:

[解析] funl是FUN的普通实例对象,而fun2是常对象,i是FUN的静态成员。funl.value( )是调用成员函数int value( ){return i-1;},值为1。Fun::i是静态成员函数i的值,i值不变为2,fun2为常对象,只能调用常成员函数int value( )const{return i+1;},所以其返回值为3。 document.getElementById("warp").style.display="none"; document.getElementById("content").style.display="block"; 查看试题解析出处>>

相关推荐

发布评论 查看全部评论