Why classes need 'InferiorClasses' to determine which method to call when multiple classes have the same method
Show older comments
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);
Accepted Answer
More Answers (0)
Categories
Find more on Methods in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!