I'm working on a huge project that I didn't start. My task is to add some additional functionality to what already is there. I'm in a situation where I have to use virtual inheritance because I have a diamond model. The situation is depicted in the following illustration:
Base class
/ \
/ \
My new class A class that was there before (OldClass)
\ /
\ /
\ /
\ /
My other new class
For this to work, both the classes in the middle have to inherit from the base through public virtual
instead of just public
. So:
class OldClass: public BaseClass {}
has to become:
class OldClass: public virtual BaseClass {}
Since this project is really huge and I'm working on a small part of it, I don't want to break it by doing this. My adhoc tests worked and the program seems to work fine, but I'm still skeptic.
So my question is: What side effects and consequences should I expect by adding the virtual
keyword? Is there anything to worry about?