How the compilers implement the virtual inheritance?
In the following code:
class A {
public:
A(int) {}
};
class B : public virtual A {
publ
It's implementation-dependent. GCC (see this question), for example, will emit two constructors, one with a call to A(1), another one without.
B1()
B2() // no A
When B is constructed, the "full" version is called:
B1():
A(1)
B() body
When C is constructed, the base version is called instead:
C():
A(3)
B2()
B() body
C() body
In fact, two constructors will be emitted even if there is no virtual inheritance, and they will be identical.