Multiple Inheritance

Multiple inheritance (several extends statements) is useful when a class wishes to include several orthogonal kinds of behavior and data, e.g. combining geometry and color. By writing several extends statements, multiple inheritance is achieved.

Show the flattened class with inheritance expanded:

1 Diamond Inheritance

A special kind of multiple inheritance is diamond inheritance, which is a problem that can arise when using multiple inheritance.

The potential problem is that we have diamond inheritance since the coordinate position defined by the fields
x and y is inherited twice. In Modelica this is not a problem, since there is a rule stating that if several identical declarations or equations are inherited, only one of them is kept.

2 Flattened Version of Rectangle with Diamond Inheritance

The Point2 definitions x, y, etc. are only present once despite being inherited twice, via VerticalLine and HorizontalLine.