I have never used virtual inheritance in real life.
I assume this would indicate a design defect, most of the time.
Also, adding virtual inheritance to solve the diamond problem somehow bothers me: as you are using two classes and run into the diamond problem, you have to modify them, but:
If there are from a library, you may not be able to modify the code.
If you can modify it, other users of the classes will pay for virtual inheritance even if they don't need it.
That's being said, I guess virtual inheritance should be used right from the beginning of the design of the classes, to solve a very particular business case (the diamond problem being then just a technical detail). Adding virtual inheritance seems like an ugly patch to me.
I may reconsider my point of view once I use it in real life :)
Indeed, as said, in most of the languages huge and complex applications can be implemented without the need for virtual inheritance. I think it's worth to know about it and probably best to avoid it in your design.
Nice article!
I have never used virtual inheritance in real life.
I assume this would indicate a design defect, most of the time.
Also, adding virtual inheritance to solve the diamond problem somehow bothers me: as you are using two classes and run into the diamond problem, you have to modify them, but:
That's being said, I guess virtual inheritance should be used right from the beginning of the design of the classes, to solve a very particular business case (the diamond problem being then just a technical detail). Adding virtual inheritance seems like an ugly patch to me.
I may reconsider my point of view once I use it in real life :)
Indeed, as said, in most of the languages huge and complex applications can be implemented without the need for virtual inheritance. I think it's worth to know about it and probably best to avoid it in your design.
Have you ever used it in real-life code?