[fpc-pascal] Skipping an the "inherited" of an ancestor

Max Vlasov max.vlasov at gmail.com
Sat Jan 15 16:57:52 CET 2011


On Sat, Jan 15, 2011 at 6:30 PM, Andrew Haines <AndrewD207 at aol.com> wrote:

> On 01/14/11 14:38, Torsten Bonde Christiansen wrote:
> > Hi List.
> >
> > Is it possible to jump a couple of levels in the inherited hierarchy
> > when calling "inherited" on a method?
> >
> > A small example of what i'm trying to achieve below (and don't mind the
> > incomplete TB class implementation).
> >
> > Kind regards,
> > Torsten Bonde Christiansen.
> >
> > ============================
> >
> > TA = class
> >   procedure DoSomething; virtual;
> > end;
> >
> > TB = class(TA)
> >   procedure DoSomething; override;
> > end;
> >
> > TC = class(TB)
> >   procedure DoSomething; override;
> > end;
> >
> > .....
> >
> > procedure TA.DoSomething;
> > begin
> >   ...
> > end;
> >
> > procedure TC.DoSomething;
> > begin
> >   inherited TA.DoSomething;  // This is not correct, but exemplifies
> > what i'm trying to achieve.
> > end;
> >
>
> I *think* I've done this before this way but test it to make sure it works:
>
> procedure TC.DoSomething:
> begin
>  (Self as TA).DoSomething;
> end;
>
>
The same vmt (virtual method table) used, so no matter how you call it, the
addresses point to new methods.

Max
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20110115/fce3100b/attachment.html>


More information about the fpc-pascal mailing list