Why classes need 'InferiorClasses' to determine which method
Date: 2023-07-31 14:57:53
Why classes need 'InferiorClasses' to determine which method to call when multiple classes have the same method
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);