Given two classes with a common virtual base class:
class Base {};
class Derived1 : public virtual Base {};
class Derived2 : public virtual Base {};
Is there any difference between these two further derived classes?:
class Derived3 : public virtual Base, public Derived1, public Derived2 {};
class Derived3 : public Derived1, public Derived2 {};
The first also derives directly from the virtual base class, but I think that has no effect, because it's shared with Derived1
and Derived2
.
They say the same thing. The only difference is that if you removed public Derived1
and public Derived2
from both definitions of Derived3
, the first one would still inherit from Base
and the second one would not.
EDIT: I haven't thought carefully about whether there is some weird cross-cast situation where the two would also behave differently, although I don't think there is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With