Hej
Hvis du opretter din nedarvet class i samme unit som classen de nedarver fra, så kan du tilgå privat members.
Men som Nørden skriver, så ryger meningen lidt med private members.
som eksempel:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TBil = class
private
Farve : Integer;
public
MotorKWh : Integer;
end;
TRacerBil = class(TBil)
procedure SetMsg;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
with TRacerBil.Create do
SetMsg;
end;
procedure TRacerBil.SetMsg;
begin
MessageDlg(IntToStr(Farve)+' '+IntToStr(MotorKwh), mtWarning, [mbOK], 0);
end;
end.
mvh Max.