C++ overload resolution [duplicate]

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;
    // …
}

Leave a Comment