Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Grudzio

Overriding methods

This topic is 6174 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I have following problem. I have two classes which look like this: TBaseClass = class public procedure Draw; virtual; abstract; end; TNextClass = class(TBaseClass) public procedure Draw(Surface : TDirectDrawSurface); override; end; When I compile (or actually do Syntax Check) I get error: "Declaration of ''Draw'' differs from previous declaration". Does it mean that I cant change number of function parameters even for virtual functions? It works with constructors, so why not with normal functions? K.

Share this post


Link to post
Share on other sites
Advertisement
As far as I know the Override Directive only works on Virtual and Dynamic functions, so I guess you might want to try the Overload Directive instead.

-Lumin

Edited by - Lumin on September 25, 2001 6:14:19 PM

Share this post


Link to post
Share on other sites
Try this...

TBaseClass = class
public
procedure Draw; virtual; abstract;
end;

TNextClass = class(TBaseClass)
public
procedure Draw(Surface: TDirectDrawSurface); reintroduce;
end;

This reintroduces the method with a different parameter list. If the inherited method was not abstract, then you could call the inherited method by using...

procedure TNextClass.Draw(Surface: TDirectDrawSurface);
begin
inherited Draw;
...
end;


Steve ''Sly'' Williams  Monkey Wrangler  Krome Studios

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!