A-A+

请将下列类定义补充完整。class Base{public:void fun(){tout<

2022-08-06 00:27:19 问答库 阅读 173 次

问题详情

请将下列类定义补充完整。
class Base{public:void fun(){tout<<"Base::fun"<<endl;}};
class Derived:public Base
{
public:
void fun()
{
______//显示调用基类的fun函数
cout<<"Derived::fun"<<endl;
};请帮忙给出正确答案和分析,谢谢!

参考答案

正确答案:Base::fun();。
Base::fun();。 解析: 本题考查的是成员函数的调用。因为横线处的作用是调用基类的fun函数,又因为派生类也碉tun()函数,所以必须对fun()函数加以限定,即Base::fun();。

考点:定义