Multiple inheritance
Not everything multiple is as good as it sounds. Multiple inheritance is when a derived class inherits from more than one base class. Usually, this works without a hitch if the multiple base classes we are inheriting from are completely unrelated.
For example, we can have a class Window
that inherits from the SoundManager
and GraphicsManager
base classes. If SoundManager
provides a member function playSound()
and GraphicsManager
provides a member function drawSprite()
, then the Window
class will be able to use those additional capabilities without a hitch.
However, multiple inheritance can have negative consequences. Say we want to create a class Mule
that derives from both the Donkey
and Horse
classes. The Donkey
and Horse
classes, however, both inherit from the base class Mammal
. We instantly have an issue! If we were to call mule.talk()
, but mule
does not override...