C
cosy
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
Tfather=class
public
function draw:string;virtual;
end;
Tchild=class(Tfather)
public
################################################
//function draw:string;override;
//function draw:string;
function draw:string;reintroduce;
#################################################
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function Tfather.draw;
begin
showmessage('Tfather.draw');
end;
function Tchild.draw;
begin
showmessage('Tchild.Draw');
end;
procedure TForm1.Button1Click(Sender: TObject);
var father:Tfather;
begin
father:=Tfather.Create;
father.draw;
end;
procedure TForm1.Button2Click(Sender: TObject);
var child:Tchild;
child:=Tchild.Create;
child.draw;
end;
end.
这里的reintroduce有什么作用?(我知道他是隐藏祖先类的虚方法)具体如何应用
怎么使用呢?
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
Tfather=class
public
function draw:string;virtual;
end;
Tchild=class(Tfather)
public
################################################
//function draw:string;override;
//function draw:string;
function draw:string;reintroduce;
#################################################
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function Tfather.draw;
begin
showmessage('Tfather.draw');
end;
function Tchild.draw;
begin
showmessage('Tchild.Draw');
end;
procedure TForm1.Button1Click(Sender: TObject);
var father:Tfather;
begin
father:=Tfather.Create;
father.draw;
end;
procedure TForm1.Button2Click(Sender: TObject);
var child:Tchild;
child:=Tchild.Create;
child.draw;
end;
end.
这里的reintroduce有什么作用?(我知道他是隐藏祖先类的虚方法)具体如何应用
怎么使用呢?