Virtual Inheritance

Technique learned in CS247 - Software Engineering Principles that basically ensures that only one copy of a base class’s member variables are inherited by grandchild derived classes.

Consider: Diamond Problem

Since two classes B and C inherit from a class A, and a class D inherits from both B and C, then D will contain two copies of A’s member variables: one via B, and one via C.

Now instead we can have classes B and C inherit virtually from class A, then objects of class D will contain only one set of the member variables from class A.

Note

Very useful technique for Multiple Inheritance