Heterogeneous hierarchies are useful to:
- Create arrays of objects that are of different classes, but part of a related hierarchy.
- Call methods of the most specific common superclass on the array as a whole
- Access properties of the most specific common superclass using dot notation with the
array - Use common operators that are supported for object arrays
- Support array indexing (scalar or nonscalar) that returns arrays of the most specific
class
Heterogeneous Array Concepts
- Heterogeneous array — An array in which two or more elements belong to different
specific classes. All elements derive from the same root superclass. - Root superclass — Class derived directly from matlab.mixin.Heterogeneous. The
root superclass can be abstract or concrete. Only concrete subclasses of the root
superclass can form heterogeneous arrays. - Most specific common superclass — The most specific class in the inheritance
hierarchy from which all the objects in a heterogeneous array derive. The most
specific common superclass can be the root superclass or a more specific superclass
shared by the objects currently in the array. - Class of a heterogeneous array — The most specific common superclass from which all
objects in the heterogeneous array derive. Adding and removing objects from a
heterogeneous array can change the most specific superclass shared by the instances.
This change results in a change in the class of a heterogeneous array. The most
specific common superclass can be abstract.
Nature of Heterogeneous Arrays
The heterogeneous hierarchy in this diagram illustrates the characteristics of
heterogeneous arrays concerning:
- Array class
- Property access
- Method invocation
10 Object Arrays