我有以下代码:
struct CommonVariables
{/*some common variables that need to be proceed*/};
struct CommonHandler
{
static void foo(const CommonVariables& vars) {/*processed vars*/}
void bar(const CommonVariables& vars) {/*processed vars*/}
};
struct AnotherVariables
{/*another variables*/};
struct AnotherHandler
{
static void foo(const AnotherVariables& vars) {/*processed vars*/}
void bar(const AnotherVariables& vars) {/*processed vars*/}
};
struct Derived : CommonHandler, AnotherHandler
{};
Run Code Online (Sandbox Code Playgroud)
当我尝试调用 Derived::foo(/ any variable type /) 或 Derived d; d.bar(/ any variable type /),编译器给我一个错误:“对'foo(or bar)'的引用不明确”。
然而在下面我有几乎相同的情况:
struct DifferentHandler
{
static void foo(const CommonVariables& vars) {} …Run Code Online (Sandbox Code Playgroud)