Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Inherited x 2

Posted on 2002-06-27
6
Medium Priority
?
165 Views
Last Modified: 2013-11-23
I'm well aware of how to call an overridden ancestor's method in the descendent class' implementation: Simply use the "inherited" keyword which will send the same parameters in the same order to the inherited ancestor method.

However, I have a situation where it would be best for a descendent class NOT to call the inherited method of its IMMEDIATE ancestor, but the method that was defined TWO classes ago!  How do I do this?
0
Comment
Question by:Pummel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 8

Expert Comment

by:TOndrej
ID: 7114821
It's neither possible (without nasty hacks with VMT) nor really needed.
If you have such situation it usually means you need to redesign your class hierarchy.

Perhaps an acceptable quick workaround might be to implement the immediate ancestor's method to call the next ancestor's method based on a parameter or perhaps a property flag.
0
 
LVL 1

Accepted Solution

by:
bes67 earned 536 total points
ID: 7115599
Try something like this:

Suppose you have following class hierarchy

type
  TSFn = function:Boolean of object;

  TGrandClass = class
  public
    function SomeFunction: Boolean; virtual;
  end;

  TBaseClass = class(TGrandClass)
  public
    function SomeFunction: Boolean; override;
  end;

  TSomeClass = class(TBaseClass)
  public
    function SomeFunction: Boolean; override;
  end;

and you want to call TGrandClass.SomeFunction from TSomeClass.SomeFunction without calling TBaseClassFunction. Well, here it is

function TSomeClass.SomeFunction: Boolean;
var gcq: TMethod;
begin
  gcq.Code := @TGrandClass.SomeFunction;
  gcq.Data := Self;
  Result := TSFn(gcq);
end;

0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7116171
interesting :)
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 7118524
? what is tsfn()
0
 
LVL 12

Expert Comment

by:Lee_Nover
ID: 7119382
type
 TSFn = function:Boolean of object;


so in the case above it's a cast :)
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7119670
oops, overread this declaration,
thanks lee for pointing out

meikl ;-)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question