我有一个继承的问题: 比方说,我有C++继承 - 暧昧功能
class Time{
protected:
void foo();
};
也
class Base: private Time{
void foo1(){ foo(); }
};
class Child: public Base, private Time{
void foo2(){ foo(); }// here my compiler says that foo is ambiguous
};
为什么FOO()不明确,如果继承在基地的时间是私人的?
PS。 只需要&仅适用于需要查看完整代码的人员,以下是GitHub项目: https://github.com/huntekah/Interior_decorator-OpenGL_Project/blob/master/Grafika-OpenGL/Interior_decorator/Display.cpp#L133 class Control(实用程序目录)由ControlObjects和ControlCamera继承,它们都是Controls的基础。显示继承控件,另外还有时间。注释行显示SetDeltaTime()不明确的地方;
私人不会隐藏它。 – Jarod42
因为'Base'和'Time'都有一个名为'foo'的成员函数,编译器不知道你试图调用哪一个函数。这里有一个这样的地方。将基地里面的命名空间隐藏起来吗 –
? –