Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

Compiler Error C2387

'type' : ambiguous base class

The compiler could not unambiguously resolve a function call because the function exists in more than one base class.

To resolve this error, either remove one of the base classes from the inheritance, or explicitly qualify the function call.

The following sample generates C2387:

// C2387.cpp
namespace N1 {
   struct B {
      virtual void f() {
      }
   };
}

namespace N2 {
   struct B {
      virtual void f() {
      }
   };
}

struct D : N1::B, N2::B {
   virtual void f() {
      B::f();   // C2387
      // try the following line instead
      // N1::B::f();
   }
};

int main() {
   D aD;
   aD.f();
}

Community Additions

ADD
Show:
© 2015 Microsoft