Does MATLAB call the double constructor on a=a+1?
이전 댓글 표시
I want to overload the double class and add some properties to it.
And i also have to override the plus function. A similar code could
look like this:
classdef myclass < double
properties (Access = protected)
foo
end
methods (Access = public)
function obj = myclass(val,foo)
obj = obj@double(val);
obj.foo = foo;
end
function out = plus(obj,in)
out = myclass(plus@double(obj,in),obj.foo);
end
end
end
However, if out = in on plus, I could just obj.foo = in.foo and call plus@double(obj,in), could I?
How does MATLAB itself determine, if a plus is in fact an increment, so out = in?
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Customize Object Display for Classes에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!