Einzelnen Beitrag anzeigen

Delphi-Lover

Registriert seit: 19. Okt 2004
Ort: Amsterdam
30 Beiträge
 
Delphi 2005 Professional
 
#1

Overriding Fields in Object..

  Alt 5. Jan 2005, 16:38
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;
...
Rob
  Mit Zitat antworten Zitat