Following code is from MSDN, I copied the code here to avoid doing my own sample, basically I'm having this problem in my project.
struct V {
virtual void vf();
};
struct A : virtual V {
void vf() override;
};
struct B : virtual V {
void vf() override;
};
struct D : A, B {
// Uncomment the following line to resolve.
// void vf() override;
};
I took a look at this SO Question where the suggestion is to use using directive to resolve ambiguous symbol.
That suggestion doesn't work for this sample, instead to resolve the problem we should explicitly override base methods in derived class.
I would like to avoid explicitly override in derived class, so the question is, why cant this be resolved with using directive as suggested in SO link above, instead of overriding? for example:
struct D : A, B {
using A::vf(); // not going to work
};
The reason why to avoid explicit override is to make use of method code in one of the base classes.