I have a theoretical question concerning how to deal with the following scenario in a language which does not allow multiple inheritance.
Imagine I have a base class Foo and from it I am wishing to create three sub-classes:
- Class Bar inherits Foo and implements functionality "A"
- Class Baz inherits Foo and implements functionality "B"
- Class Qux inherits Foo and implements functionalities "A" and "B"
Imagine that the code to implement functionalities "A" and "B" is always the same. Is there a way to write the code for "A" and "B" only once, and then have the appropriate classes apply (or "inherit") it?