My 2 Cents Virtual Base Class

Swati Mishra

Content Writer
The concept of virtual base class is to have only one copy of the base class member in memory.
Inheriting a class more than once through multiple paths create multiple copies of base class members in the memory. Thus, by declaring the base class inheritance is virtual, only one copy of the base class is inherited. A base class inheritance can be specified as virtual by using the virtual qualifier.
Syntax

Class A
{
….
}
Class B : virtual public A
{
……
}
Class C : virtual public A
{

}
Classes B and C use the virtual keyword to inherit class A, so the class A is the virtual base class
 
Top