It will not compile for three reasons, none of which has anything to do with virtual inheritance (well, maybe the last one).
You forgot the semicolons after class definitions
Your inheritance is closed
D::foo() ambiguous unless explicitly redefined
By the way, the definition of D itself is poorly developed, and not just the fact that you are trying to use it. I mean, if your main() function was empty, it still wonβt compile.
And "Will it compile?" has the obvious answer "Why don't you try?"
Quote from the standard: 10.3.10
The following example shows a function that does not have a unique target interceptor:
struct A { virtual void f(); }; struct VB1 : virtual A {
Armen Tsirunyan
source share