8

Code:

class A1 {};
class A2 {};

template <class M>
class Base
{
public:
  void func(M &m) const {}
};

class Derived : public Base<A1>, public Base<A2>
{};

int main()
{
  Derived d;
  A1 a1;
  d.func(a1);
}

Compilation error:

AmbiguousFunction.cpp: In function \u2018int main()\u2019:
AmbiguousFunction.cpp:19: error: request for member \u2018func\u2019 is ambiguous
AmbiguousFunction.cpp:9: error: candidates are: void Base<M>::func(M&) const [with M = A2]
AmbiguousFunction.cpp:9: error:                 void Base<M>::func(M&) const [with M = A1]

Why do I get this error? Are two flavors of func one with A1 and snother with A2 as argument not created?

toutnom
  • 244
  • 1
  • 7

0 Answers0