MATLAB Object-Oriented Programming

(Joyce) #1

Referring to Prop1 using dot notation returns the value of Prop1 for each object in the
array.


Method Invocation


To invoke a method on a heterogeneous array, the class of the array must define or inherit
the method as Sealed. For example, suppose RootSuperclass defines a Sealed
method called superMethod.


Call the method on all objects in the array a2:


a2 = [SpecificA,SpecificB,SpecificC];
a2.superMethod


Sealing the method (so that it cannot be overridden in a subclass) ensures that the same
method definition exists for all elements of the array. Calling that method on a single
element of the array invokes the same method implementation as calling the method on
the whole array.


Unsupported Hierarchies


Heterogeneous hierarchies cannot have ambiguities when obtaining default objects,
determining the class of the array, and converting class objects to other types. Members
of the hierarchy can derive from only one root superclass (that is, from only one direct
subclass of matlab.mixin.Heterogeneous).


This diagram shows a hierarchy that is not allowed:


Designing Heterogeneous Class Hierarchies
Free download pdf