Products & Services Solutions Academia Support User Community Company

Learn more about MATLAB   

Specifying 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 metaclass 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 superior to class1 and class2.

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

The ? operator combined with a class name creates a metaclass 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.

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 Working with Meta-Classes 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-2009- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS