代码
#include <iostream>
using std::cout;
using std::endl;
class Base1{
public:
void foo(){cout<< "Base1::foo"<<endl;};
};
class Base2{
private:
void foo(){cout<< "Base1::foo"<<endl;};
};
class Dirived : public Base1,public Base2{};
int main(){
Dirived d;
d.foo();
return 0;
}
d.foo();这一行编译器会报错 error: "Dirived::foo" is ambiguous
那么既然,Bas2的foo是一个私有函数,在Dirived类中并不可见,为什么编译器还傻傻的说ambiguous呢?