This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Establish superior class relationship


superiorto('class1', 'class2', ...)


superiorto('class1', 'class2', ...) establishes that the class invoking this function in its constructor has higher precedence than the classes in the argument list.

The superiorto function establishes a precedence that determines which object method MATLAB® calls. Use this function only from a constructor that calls the class function to create an object. For classes defined with classdef statements, see Class Precedence.


Show function dispatching:

a is an object of class class_a, b is an object of class class_b, and c is an object of class class_c. The constructor method for class_c contains the statement superiorto('class_a'). Then, either of the following two statements:

e = fun(a,c);
e = fun(c,a);

invokes class_c/fun.

If you call a function with two objects having an unspecified relationship, MATLAB considers the two objects to have equal precedence. In this case, MATLAB calls the left-most object method. So fun(b,c) calls class_b/fun, while fun(c,b) calls class_c/fun.

See Also

Introduced before R2006a

Was this topic helpful?