die Mehrfachvererbung (pl. -en) – multiple inheritance
Multiple inheritance is when one class inherits from two or more classes. (You could have a chain of classes inheriting from one another, and have grandparent classes, but this would not be considered multiple inheritance. Just normal inheritance.)
Multiple inheritance is a tricky thing. Because of the complexity and its problem, not many languages do not allow for multiple inheritance.
One of the most famous is the diamond problem (das Diamond-Problem), nicknamed “the deadly diamond of death”.
It is so named because the class inheritance diagram in this problem represents a diamond.
It arises in its most simple form when you have 4 classes. For now, I’ll call them A, B, C, and D.
B and C both inherit from A. D inherits from both B and C.
The question is, what happens when a method from A is overridden in both classes B and C?
Which parent (B or C) does D inherit the method from?
(In practice, different languages handle this… differently.)
Etymology
Since the previous post was on inheritance (Vererbung), I will look into Mehrfach this week.
Duden simply says that it comes from the French multiple.[1]
Looking into mehr and -fach separately, I found the following:
- mehr comes from Middle High German mēr(e) and Old High German mēr(o)[2]
-fach (the suffix) comes from Late Middle High German -vach, probably from the old word -valt (-fältig).[3] Either way, it comes from the noun das Fach, which is also from Middle High German vach, meaning a piece, part, section of a wall.[4]
Leave a Reply