Hi,
I'm trying to extend the inputParser class, and hereby also extend the method parse() from that class.
Is it at all possible? The documentation seems to explain how to do this:
Here is my subclass with extended method:
classdef myInputParser < inputParser
properties
Extra
end
methods
% Class constructor
function obj = myInputParser()
obj.Extra.test = 0;
end
% Extend inputParser superclass method parse()
function parse(obj, varargin)
% preprocessing steps
parse@inputParser(obj, varargin{:});
% postprocessing steps
obj.Extra = obj.Results;
end
end
end
I create the object, and parse the input like so:
p = myInputParser;
p.parse(varargin{:})
When calling the parse() method on the object, it doesn't seem to call the extended parse() in the subclass.
What am I missing? Any help would be greatly appreciated.

 채택된 답변

No Name
No Name 2018년 12월 14일

0 개 추천

When I restarted MATLAB, it worked.
After that I read about the command "clear classes", which might have helped as well. I had to clear the cache or something.

댓글 수: 2

per isakson
per isakson 2018년 12월 14일
편집: per isakson 2018년 12월 14일
Yes, but the name of the constructor should be identical to the name of the class.
And the method
function parse(obj)
% preprocessing steps
parse@inputParser(obj);
% postprocessing steps
obj.Extra = obj.Results;
end
should read something like
function parse(obj,varargin)
% preprocessing steps
parse@inputParser(obj,varargin{:});
% postprocessing steps
obj.Extra = obj.Results;
end
No Name
No Name 2018년 12월 14일
Correct, I edited my original post.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Software Development에 대해 자세히 알아보기

제품

태그

질문:

2018년 12월 13일

편집:

2018년 12월 14일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by