Learn how to implement subclasses, call superclass methods from subclasses, and control what classes can derive from a superclass.
superclasses | Names of superclasses |
matlab.mixin.Heterogeneous | Superclass for heterogeneous array formation |
Hierarchies of Classes — Concepts
Organizing classes into hierarchies facilitates the reuse of code.
Designing Heterogeneous Class Hierarchies
Heterogeneous arrays can contain objects of different class, but all objects in the array must derive from a common superclass.
Specify superclasses on the classdef line after the class name.
Specify superclasses on the classdef
line in the class file.
Call Superclass Methods on Subclass Objects
Subclass methods can override inherited superclass methods. Subclass methods can call the superclass method that they override.
Control Sequence of Constructor Calls
Control the order in which MATLAB® constructs objects in class hierarchy.
Subclasses can modify inherited methods.
Subclasses can modify inherited properties that are abstract or private.
Multiple inheritance can lead to conflicting definitions. All superclasses must be free of conflicts in definition.
Classes can restrict the classes that can derive from it.
Enable both handle and value classes to derive from a specific class.
How to Define Handle-Compatible Classes
Handle compatible classes have applications for mixin and abstract superclasses.
Methods for Handle Compatible Classes
Handle compatible class methods must work with both handle and value objects.
Handle-Compatible Classes and Heterogeneous Arrays
Heterogeneous class hierarchies impose certain restrictions when classes are handle compatible.
Determine what level of access is allowed for properties, methods, and events.