Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force derived class to call base function in MATLAB?

Base class has a function f. Derived class overwrites the function f. I want to call base class' f for an object of the derived class. How can I do this?

Here is the code sample.

    classdef base

        methods ( Access = public )
            function this = f( this )
                disp( 'at base::f' );
            end

        end
    end

    classdef derived < base

        methods ( Access = public )
            function this = f( this )
                % HERE I WANT TO CALL base::f
                [email protected](); % this is an error

                disp( 'at derived::f' );
            end

        end
    end

d = derived();
d.f();
% here the result should be
% at base::f
% at derived::f
like image 316
Vahagn Avatar asked Sep 16 '11 12:09

Vahagn


1 Answers

Instead of

[email protected]();

it's

f@base(this)
like image 155
Jonas Avatar answered Sep 22 '22 09:09

Jonas