Modifiers may also occur in extends clauses, and are applied to inherited element declarations in a similar way as modifiers in short class definitions. We inherit the contents of the class LowPassFilter1 into the class LowPassFilter20C, and give the same modifiers as in the short class definition of LowPassFilter20 above.
Another example demonstrates that modifiers in extends clauses can be applied to elements that are local classes such as Voltage within the class LowVoltage below.
Notice that the variables vhigh.v1 and vhigh.v2 have the unit "kV".
The possibilities to apply modifiers are not limited to declared elements that are variables or local classes. It is actually possible to modify elements that are extends clauses in superclasses, so-called nested extends clauses, even though such clauses dissappear in the expanded subclass.
The classes A and B can be combined and expressed as Bexpanded.
The class C below modifies the nested extends clause of class B, which can be considered to be nested one level down in the inheritance chain (where C inherits B which inherits A). The most recent, i.e. "outermost", modifiers in the inheritance chain have priority over previous modifiers.
Expand the class C:
The classes A, B and C are equivalent to the single class Cexpanded.
The class C2 below illustrates the rule that the most recently applied modifications like b = 1 overrides modifications like A(b = 2) of a nested extends clause, since b = 1 is further down in the modification chain. The instance bcomp has bcomp.b = 1, which overrides b = 2 from the nested modifier.
Look at the expanded class: