Why classes need 'InferiorClasses' to determine which method to call when multiple classes have the same method
Ältere Kommentare anzeigen
Document from here .I know how to use InferiorClasses.But I don't know why I need to use InferiorClasses?
For example,there is two classes,I don't use InferiorClasses! When I use classA's methods,just use " obj_classA.MyMethod". When I use classB's methods,just use " obj_classB.MyMethod".
it's very flexible!So Why classes need 'InferiorClasses' to determine which method to call when multiple classes have the same method?
classdef classA
properties
a;
end
methods
function obj=classA(value)
obj.a=value;
end
function MyMethod (obj,obj_classB)
disp('The MyMethod of classA Called!');
end
end
end
classdef %(InferiorClasses = {?classA}) classB
properties
b;
end
methods
function obj=classB(value)
obj.b=value;
end
function MyMethod (obj,obj_classB)
disp('The MyMethod of classB is Called!');
end
end
end
obj_classA = classA(3);
obj_classB = classB(4);
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Methods finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!