5
基類有一個函數f。 派生類覆蓋函數f。 我想調用基類'f爲派生類的對象。我怎樣才能做到這一點?強制派生類在MATLAB中調用基函數?
以下是代碼示例。
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
@Vahagn:它將disp已'在衍生:: F',因爲該聲明被調用到f @基地後執行。雖然我不明白無限循環。 – Jonas
@Vahagn:以下是文檔中的鏈接:http://www.mathworks.com/help/techdoc/matlab_oop/bsa1q42.html – Jonas