classdef Num
properties
value
end
methods
% Constructor
function self = Num(n)
self.value = n;
end
% Accessor
function disp(self)
fprintf('Num: %d\n', self.value);
end
% Overloadding
function self = sqrt(self)
self.value = 10*sqrt(self.value);
end
end
end
classdef Num
properties
value
end
methods
% Constructor
function self = Num(n)
self.value = n;
end
% Accessor
function disp(self)
fprintf('Num: %d\n', self.value);
end
% Overloadding Operators
% +
function self = plus(self, right)
self.value = self.value + right.value;
end
% <
function l = lt(self, right)
if self.value < right.value
l = true;
else
l = false;
end
end
end
end