Why is inheritance of a const/non-const function overload ambiguous?

The problem is that you don't actually have one unified overload-set, in which the mutable variant would be unambiguously best, but two distinct overload-sets, in A and B, and the compiler will not automatically merge them.

Put

using A::get;
using B::get;

in C to merge the overload-sets and thus resolve the ambiguity.


Ambiguity occurs when compiler tries to figure out to what entity does the name get refer to, prior to overload resolution. It can be a name of function from class A or from class B. In order to build a list of overloads complier needs to select just one of the classes to pull functions from. In order to fix it you can bring that name from both of the base classes into derived class (and make them public):

class C : public A, public B { public: using A::get; public: using B::get; };