The two “overloads” aren't in the same scope. By default, the compiler only considers the smallest possible name scope until it finds a name match. Argument matching is done afterwards. In your case this means that the compiler sees B::DoSomething
. It then tries to match the argument list, which fails.
One solution would be to pull down the overload from A
into B
's scope:
class B : public A {
public:
using A::DoSomething;
// …
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…