3.4 Multiple inheritance
Multiple inheritance is a touchy subject. In principle, it’s simple: a subclass that inherits from more than one parent class can access functionality from both of them. In practice, it requires some care to be sure any method overrides are fully understood.
As a humorous rule of thumb, if you think you need multiple inheritance, you’re probably wrong, but if you know you need it, you might be right. This is often taken to be a dire warning: don’t attempt multiple inheritance. We don’t think this dire warning is appropriate if a few patterns are followed.
The simplest and most useful form of multiple inheritance follows a design pattern called the mixin. A mixin class definition is not intended to exist on its own, but is meant to be inherited by some other class to provide extra functionality. For example, let’s say we wanted to add functionality to our Contact class that allows sending an email to self...