Virtual methods work the same way in the case of multiple inheritance as in the case of single inheritance. Let us examine the example in listing 5.
Listing 5: | virtualmethod |
In this case, both line 27 and line 29 invoke C::m1, which in return calls the m1 of both superclasses.
Note that line 28 ends up calling C::m1(), and line 30 ends up calling C::m1() as well.
This is because the invocation of line 5 is determined at run time.