A
archy
Unregistered / Unconfirmed
GUEST, unregistred user!
Tmy= class
private
x:integer;
public
function Get_x():integer;
constructor Create;
end;
Tsub = class(Tmy)
public
constructor Create;
end;
constructor Tmy.Create;
begin
x:=8;
end;
procedure TForm1.FormShow(Sender: TObject);
var a:Tsub;
begin
a:=Tsub.Create;
caption:=(inttostr(a.Get_x))
a.Free;
end;
constructor Tsub.Create;
begin
inherited;//关键在于这一句,加了caption为8,不加为默认值0,在VC中不加(当然没有此语句)也是8
end;
哪位高手能指点一下呢?另:Delphi的书中讲类和继承的太少了,138元的就那么一点点,<Mastering Delphi 5>也不多。请推荐。
private
x:integer;
public
function Get_x():integer;
constructor Create;
end;
Tsub = class(Tmy)
public
constructor Create;
end;
constructor Tmy.Create;
begin
x:=8;
end;
procedure TForm1.FormShow(Sender: TObject);
var a:Tsub;
begin
a:=Tsub.Create;
caption:=(inttostr(a.Get_x))
a.Free;
end;
constructor Tsub.Create;
begin
inherited;//关键在于这一句,加了caption为8,不加为默认值0,在VC中不加(当然没有此语句)也是8
end;
哪位高手能指点一下呢?另:Delphi的书中讲类和继承的太少了,138元的就那么一点点,<Mastering Delphi 5>也不多。请推荐。