Overload
Overload Functions
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
			
function numTest()
    % Create a Num Object
    n = Num(10);
    
    n = n.sqrt();    
    n.disp();
    
    n = sqrt(n);
    n.disp();
end
		
Overload Operators
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
			
function numTest()
    % Create a Num Object
    n = Num(10);
    n2 = Num(80);
    
    temp = n + n2;
    disp(temp);
    
    if n < n2
        fprintf('n < n2\n');
    end
end