Inheritance


A major advantage with object-orientation is the ability to extend the bahavior and properties of an existing class. The original class (base class or superclass), is extended to create a more specialized version (subclass). By doing this the field declarations, equations and other contents are inherited by the subclass, and can be reused.


1 ColorData

This is an example of extending a simple Modelica class, ColorData. Color inherits the data fields (red, blue and green) from ColorData.







The class
ColoredPoint inherits from multiple classes, both Point and Color.



2 Flattening of Color

Make a call to flatten the class Color.