Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Overriding Fields in Object.. (https://www.delphipraxis.net/37412-overriding-fields-object.html)

Delphi-Lover 5. Jan 2005 16:38


Overriding Fields in Object..
 
Hello,

Is it possible to override fields instead of Methods. What I like to do is:

A BaseObject with a field myQuery: TQuery;
In the object I use procedures/functions with the myQuery var to do like : add, insert, active and so.

When I make a new object inherited from BaseObject I like to make myQuery of type TADOQuery (overriding the myQuery) so that I can use the functions and procedures inherited from the BaseObject.

I think it is not possible, but is there a good Object Oriented way to do what I want?

Thanks,

Delphi Lover.

Delphi-Quellcode:
TPortObject = Class(TObject)
 Private
  qryPort : TQuery;
 public
  procedure AllPort;
end;

procedure TPortObject.AllPort;
Begin
 qryPort.SQL.Add('Select * from Port');
 qryPort.Active:=True;
End;


TADOPortObject = Class(TPortObject) //inherited
 Private
  qryPort : TADOQuery;
 public
  constructor Create;
end;

constructor TADOPortObject.Create;
Begin
 qryPort:=TADOQuery.Create;
 qryPort.....
 ....
End;


MainSource:

aPortObject:=TADOPortObject.Create;
aPortObject.AllPort;
...


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:08 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz