Sometimes there is a need to extend the behavior and properties of an existing class. The original class, known as the superclass, is extended to create a more specialized version of that class, known as the subclass. Inheritance of a class is achieved by using the keyword extends. The behavior and properties of the original class (field declarations, equations etc.) is reused and inherited by the subclass.
This is an example of extending a simple Modelica class, ColorData.
Simulation of ErrorColor gives error since we try to declare a new variable red, of the type Integer, although it alredy exists with the type Real.
If two identical equations are locally declared in a subclass, then one of the equations are discarded. The class Color2 is identical to the class Color, since the equation defined in Color2 is identical to the one inherited from class Color, and only one of these equations are kept.
Equations that are mathematically equivalent, but not syntactically equivalent are not discarded. Since this is the case in class Color3, both equations are kept. This leads to an overdetermined system of equation.
When simulating the class Color3 we get too many equations.