Skip to Main Content Skip to Search
Product Documentation

Class Precedence

InferiorClasses Attribute

You can specify the relative precedence of user-defined classes using the class InferiorClasses attribute. Assign a cell array of class names (represented as meta.class objects) to this attribute to specify classes that are inferior to the class you are defining. For example, the following classdef declares that myClass is dominant over class1 and class2.

classdef (InferiorClasses = {?class1,?class2}) myClass
   ...
end

The ? operator combined with a class name creates a meta.class object. This syntax enables you to create a meta.class object without requiring you to construct an actual instance of the class.

MATLAB built-in classes are always inferior to user-defined classes and should not be used in this list.

The built-in classes include: double, single, char, logical, int64, uint64, int32, uint32, int16, uint16, int8, uint8, 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:

See Concatenating Objects of Different Classes for more information on creating object arrays.

More Information

See Determining Which Method Is Invoked for more on how the MATLAB classes dispatch when evaluating expressions containing objects.

See Class Precedence and MATLAB Path for information on how the location of a class definition on the MATLAB path determines its precedence.

See Use Class Metadata for information on meta-class objects.

No Attribute Inheritance

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

  


Recommended Products

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS