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();
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for