问题描述
代码是:
#include <iostream>
using namespace std;
class A
{
public:
void fun()
{
cout << "A::fun()" << endl;
}
void fun(int i)
{
cout << "A::fun(int)" << endl;
}
};
class B:public A
{
public:
void fun()
{
cout << "B::fun()" << endl;
}
};
int main()
{
B b;
b.fun(5); // throws an error.
return 0;
}
在公共继承中,所有成员函数都可以通过派生对象访问。但是,当我尝试访问基类的成员函数时,它抛出了一个错误。为什么?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)