MATLAB Object-Oriented Programming

(Joyce) #1
For example, the following classdef declares that MyClass is dominant over
ClassName1 and ClassName2.

classdef (InferiorClasses = {?ClassName1,?ClassName2}) MyClass
...
end

The? operator combined with a class name creates a meta.class object. See
metaclass.

The following MATLAB classes are always inferior to classes defined using the classdef
syntax and should not be used in this list.

double, single, int64, uint64, int32, uint32, int16, uint16, int8, uint8, char,
string, logical, cell, struct, and function_handle.

Dominant Class

MATLAB uses class dominance when evaluating expressions involving objects of more
than one class. The dominant class determines:


  • Which class method to call when more than one class defines methods with the same
    names.

  • The class of arrays that are formed by combining objects of different classes, assuming
    MATLAB can convert the inferior objects to the dominant class.


No Attribute Inheritance

Subclasses do not inherit a superclass InferiorClasses attribute. Only classes
specified in the subclass InferiorClasses attribute are inferior to subclass objects.

See Also


More About



  • “Class Precedence and MATLAB Path” on page 6-19

  • “Dominant Argument in Overloaded Graphics Functions” on page 9-49


6 Defining and Organizing Classes

Free download pdf