(20)有如下程序:
#include
usingnamespacestd;
intmain()
{
int*p;
*p=9;
cout<<"Thevalueatp:"<<*p;
return0;
}
编译运行程序将出现的情况是
A)够编译时出现语法错误,不能生成可执行文件
B)运行时一定输出:Thevalueatp:9
C)运行时一定输出:Thevalueatp:*9
D)运行时有可能出错
(21)有如下程序:
#include
usingnamespacestd;
intmain()
{
voidfunction(doubleval);
doubleval;
function(val);
cout<
return0;
}
voidfunction(doubleval)
{
val=3;
}
编译运行这个程序将出现的情况是
A)编译出错,无法运行B)输出:3
C)输出:3。0D)输出一个不确定的数
(22)有如下类定义:
classAA
{
inta;
public:
intgetRef()const{return&a;}//①
intgetValue()const{returna;}//②
voidset(intn)const{a=n;}//③
friendvoidshow(AAaa)const{cout<//④
};
其中的四个函数定义中正确的是
A)①B)②C)③D)④
(23)有如下程序:
#include+
usingnamespacestd;
#include
usingnamespacestd;
classBase
{
public:
voidfun(){cout<<"Base::fun"<
};
classDerived:publicBase
{
public:
voidfun()
{
cout<<"Derived::fun"<
}
};
intmain()
{
Derivedd;
d。fun();
return0;
}
已知其执行后的输出结果为:
Base::fun
Derived::fun
则程序中下划线处应填入的语句是
A)Base。fun();B)Base::fun()C)Base->fun()D)fun();