[DISABLE, INFORMATION ,WARNING,ERROR]
The virtual keyword ensures that only one copy of the subobject is included in the memory scope of the object. This single copy is the PSEUDO BASE CLASS.
class A{ //base class
// member list
};
class B : public virtual A { //derived class
public:
// member list
};
class C : public virtual A { //derived class
public:
// member list
};
class D : public B, public C { //derived class
public:
// member list
};
According to this definition, an object 'd' would have the following memory layout:
A part
B part
------
A part
C part
------
D part
But the 'virtual' keyword makes the compiler to generate the following memory layout.
B part
------
C part
------
A part // This is the PSEUDO BASE CLASS of class D
------
D part
In addition, a pointer to the PSEUDO BASE CLASS is included in each base class that previously derived from virtual base class (here B and C classes).