Help for inherited method

조회 수: 1 (최근 30일)
Patrick Mboma
Patrick Mboma 2015년 9월 8일
댓글: Patrick Mboma 2015년 9월 9일
Hi,
I have the following problem. I have two classes, say second_class and first_class, where second_class<first_class i.e. second_class inherits from first_class . Both of those classes have a method, say "do_something" and I would like to write Help for "do_something" in second_class. In this method, second_class first applies do_something from first_class and then does some further processing. I guess there is no way to "inherit" the help from first_class and then add a description of what is specific to second_class. I just have to manually copy the help from first_class, paste it in second_class and then add the specifics of second_class. Am I wrong on this? The setup for second_class could look as follows:
classdef second_class < first_class
properties
...
end
methods
function out=do_something(varargin)
out=do_something@first_class(varargin{:})
out=do_something_else(out);
end
end
end
The problem is somewhat related to a question I asked earlier but it is slightly different. There I was asking whether two functions with identical behavior could share the same help without having to copy and paste.
There was an indirect solution that I liked very much, but I guess it cannot be applied to this case?

채택된 답변

Steven Lord
Steven Lord 2015년 9월 8일
No, there is no way to "inherit" help text. You could do something similar to what IMAGESC does, which is to say that IMAGESC behaves like IMAGE except for ... and have your function See Also the method of the base class that it invokes.
  댓글 수: 1
Patrick Mboma
Patrick Mboma 2015년 9월 9일
Dear Steven,
Thank you for your answer, I did not fully understand it last time. But now I think I do.
I can write in the help for second_class to refer to help from the first_class. And then add extra lines for the specifics of the second_class.
I think this solution is more suited to this current problem but it can be used also in the my previous problem.
Thank you so much

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Construct and Work with Object Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by