C++ Virtual Base Class Example Tutorial is today’s topic. Virtual base classes come in handy during  multiple inheritance. During  inheritance, it is quite common to receive multiple instances of a single base class via different routes which can create ambiguity. Due to the fact that the sub child class receives multiple instances of the same base class when inheriting from more than one child classes, confuses the compiler and it shows an error message for the same.

C++ Virtual Base Class

The problem with regular base classes is that while inheriting them, we can have multiple child classes from them. Then after some point, those multiple child classes can be further inherited together by a single sub-level child class. In that case, the sub-level child class receives multiple instances of the same base class via different child classes.

#c++ #c++ virtual base class

C++ Virtual Base Class Example Tutorial
8.85 GEEK