也许我有两个具有相同功能名称和参数的接口,但具有不同的返回值:
struct A { virtual void foo() = 0; };
struct B { virtual int foo() = 0; };
Run Code Online (Sandbox Code Playgroud)
如何定义继承此接口的类C(如果可能的话)?例如,我写了一些未编译的伪代码:
// this code is fake, it doesn't compiled!!
struct C : A, B
{
// how to tell compiler what method using if referenced from C?
using void foo(); // incorrect in VS 2012
// and override A::foo() and B::foo()?
virtual void foo() { std::cout << "void C::foo();\n"; } // incorrect
virtual int foo() { std::cout << "int C::foo();\n"; return …Run Code Online (Sandbox Code Playgroud)