Virtual base classes in C++ programs are used in virtual inheritance in such a way that it prevents multiple "instances" of a given class from appearing in an inheritance hierarchy when making use of multiple inheritances.
Below are where the Virtual base class can be used
Example:
#include <iostream>
class B
{
public:
void display()
{ cout<<"Content of base class.n"; }
};
class D : public B
{
public:
void display()
{ cout<<"Content of derived class.n"; }
};
void main()
{
B *b;
D d;
b->display();
b = &d; /* Address of object d in pointer variable */
b->display();
getch();
}