
Josh S. answered 05/02/20
Software Developer Specializing in C++
Generally, you want to use virtual inheritance when dealing with multiple class generations that lead to ambiguities.
Here's an example:
Suppose you have a class named "Person" from which 2 subclasses derive. We will call these "Student" and "Teacher". At this moment, there is not necessarily a need for virtual function in the parent class, "Person", but suppose we have a new class that draws from both "Student" and "Teacher" which we will call "TA". Because the parent class "Person" was already called and defined in both "Student" and "Teacher", it will therefore be defined twice in the grandchild class "TA", causing ambiguities. Using virtual functions in "Person" would pass the responsibility to define its functions to its children, or even grandchildren, classes, eliminating this source of ambiguity.