[Top][All Lists]

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

Re: calling overriden method from child class from class folder

From: Julien Bect
Subject: Re: calling overriden method from child class from class folder
Date: Tue, 16 Feb 2016 15:44:41 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.8.0

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 ?

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, ...)

b) Otherwise, I think the answer is: you can't (that what encapsulation and overloading are for).


reply via email to

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