Registriert seit: 29. Mär 2009
439 Beiträge
|
AW: Problem mit Klassendesign
31. Jan 2017, 16:10
Die eingestreuten "abstract"s ersparen einem leere Methoden-Hülsen zu erzeugen.
Delphi-Quellcode:
type
TDatabase = class abstract
public
procedure ConnectDB(host,user,pw: String); virtual; abstract;
procedure SelectDB(DBName: String); virtual; abstract;
procedure SQLQuery( Query: String; var Cols:TCols; var Rows:TRows); virtual; abstract;
end;
TMySQL = class(TDatabase)
public
procedure ConnectDB(host,user,pw: String); override;
procedure SelectDB(DBName: String); override;
procedure SQLQuery( Query: String; var Cols:TCols; var Rows:TRows); override;
end;
TMySQLPhpTunnel = class(TDatabase)
public
procedure ConnectDB(host,user,pw: String); override;
procedure SelectDB(DBName: String); override;
procedure SQLQuery( Query: String; var Cols:TCols; var Rows:TRows); override;
end;
implementation
procedure ZeigeInGui( SQL: TDatabase); //<----- wichtig ist hier!
var
i,j: Integer;
begin
SQL.SQLQuery(' SELECT * FROM TestTabelle');
for i:=0 to High(Rows[0])
for j:=0 to High(Rows) do StringGrid1.Cells[i,j] rows[i,j]; //nur exemplarisch
end;
|
|
Zitat
|