matlab copy
%http://cn.mathworks.com/help/matlab/ref/matlab.mixin.copyable-class.html
%https://cn.mathworks.com/matlabcentral/answers/41674-deep-copy-of-handle-object
classdef tempobj < handle
properties
data
end
methods
function this = tempobj(v)
this.data = v;
end
function c = plus(a,b)
c = tempobj(a.data + b.data);
a.data = 4;
end
end
methods (Static)
function demo()
a = tempobj(1);
b = tempobj(2);
c = a+b;
a,b,c % 4 2 3
end
end
end