全部题库 / C++ / 试题详情
单选题 C++
2011-12-20

在下列横线处应添加的语句是(      )。
class Base {public:void fun(){cout<<"Base::fun"<<endl;}};
class Derived:public Base
{
public:
void fun()
{
                                  //显示调用基类的fun函数
    cout<<"Derived::fun"<<endl;
}};

A.Derived::fun
B.Base::fun();
C.Pubic::fun
D.fun();

参考答案

B

答案解析

此题考查的是成员 函数的调用。因为横线处的作用是调用基类的fun函数,又因为派生类中也有fun()函数,所以必须对fun()函数加以限定,即 Base::fun();。