N
netbug
Unregistered / Unconfirmed
GUEST, unregistred user!
请看:
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;
ta=class
s1:string;
constructor create;
procedure show;(或:procedure show;virtual;)
end;
tb=class(ta)
s2:string;
constructor create;
procedure show;(或:procedure show;override;)
end;
var
Form1: TForm1;
implementation
constructor ta.create;
begin
s1:='string';
end;
procedure ta.show;
begin
showmessage(s1);
end;
constructor tb.create;
begin
inherited;
s2:='type';
end;
procedure tb.show;
begin
inherited;
showmessage(s2);
end;
{$R *.DFM}
var x1:ta;x2:tb;
procedure TForm1.Button1Click(Sender: TObject);
begin
x1:=ta.Create;
x1.show;
x2:=tb.create;
x2.show;
end;
我想测试一下:用virtual、override与不用virtual、override的区别,
但我在以上程序中看不到用什么不同,请问我看如何做才能看到
必须用virtual、override?
谢谢。
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
end;
ta=class
s1:string;
constructor create;
procedure show;(或:procedure show;virtual;)
end;
tb=class(ta)
s2:string;
constructor create;
procedure show;(或:procedure show;override;)
end;
var
Form1: TForm1;
implementation
constructor ta.create;
begin
s1:='string';
end;
procedure ta.show;
begin
showmessage(s1);
end;
constructor tb.create;
begin
inherited;
s2:='type';
end;
procedure tb.show;
begin
inherited;
showmessage(s2);
end;
{$R *.DFM}
var x1:ta;x2:tb;
procedure TForm1.Button1Click(Sender: TObject);
begin
x1:=ta.Create;
x1.show;
x2:=tb.create;
x2.show;
end;
我想测试一下:用virtual、override与不用virtual、override的区别,
但我在以上程序中看不到用什么不同,请问我看如何做才能看到
必须用virtual、override?
谢谢。