Multiple Inheritance
Oct 23, 2012 · Commentscode c++
What is the output to the following code?
Output
Foo FooToo Bar FootTooBar
Why?
An instance of FooTooBar needs to be created according to main()
To create that instance, we first need the base classes too, hence FooToo and Bar classes
Now notice the keyword virtual everytime inheritance is defined
This does half the magic by ensuring that the member data instances are shared with any other inclusions of that same base in further derived classes
This is very handy for multiple inheritance
As an exercise you may try to remove virtual from some derived class and see what results you get.