help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: calling overriden method from child class from class folder


From: Carnë Draug
Subject: Re: calling overriden method from child class from class folder
Date: Tue, 16 Feb 2016 17:38:37 +0000

On 16 February 2016 at 15:44, Julien Bect
<address@hidden> wrote:
>
>Le 16/02/2016 15:26, Carn? Draug a ?crit :
>> I came across this question [1] on stack overflow today.  I found the
>> question a bit confusing (the OP is mixing classdef documentation and
>> class folders), but it basically boils down to "How to call a method
>> from the parent class when the method has been overloaded"?
>>
>> I looked at our documentation and even on Mathworks documentation and I
>> couldn't find a way to do it.  In the end I suggested to keep the object
>> of the parent class around in order to call its methods directly [2].
>
> I'm not sure I get the question correctly, but I can try to answer
> anyway ;-)
>
> Assume that you have a class B, which is derived from a class A.
>
> Then you have toto() implemented in @A/toto() and overloaded in @B/toto().
>
> And the question is : if I have an object x of class B, how can I call
> @A/toto on it ?

Yes, that is the question.

> The answer depends on where you want to call it from :
>
> a) If you in a method of class B, for instance @B/toto(), the answer is:
> toto(x.A, ...)
>

That is what I did but I find this solution kind of ugly.  You shouldn't
have to keep x.A around to call its methods.  So my question was if there's
a more elegant way to do this.

Carnë



reply via email to

[Prev in Thread] Current Thread [Next in Thread]