When you type f(x)
, with x
belonging to several classes (say, A, B and C), the computer has to decide which f
method to call (that from class A, B, or C): this is called "method lookup".
Multiple inheritance often poses problems when the code evolves.
Imagine you have written two base classes A and B, and class C inherits from both. Everything works fine.
A few months later, a developer, who uses class A, and is completely unaware of classes B and C (he does not need them), adds a new method to class A. Unbeknownst to him, there is already a method with the same name in class B. What happens to objects of class C? Will the method from A or B be used? In some languages, the code may fail, in others you can have an undefined behaviour and a very hard-to-catch bug.