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
this@base.f(); % 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
Instead of
it’s