unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
TFirst = class
public
procedure ShowMe; overload;
procedure ShowMe(WhatName :String); overload;
end;
TSecond = class(TFirst)
private
procedure ShowMe;
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ TSecond }
procedure TSecond.ShowMe;
begin
inherited; //调用TFirst.ShowMe();
inherited ShowMe('inherited ShowMe(参数)'); //调用TFirst.ShowMe(WhatName :String);
end;
{ TFirst }
procedure TFirst.ShowMe;
begin
ShowMe('');
end;
procedure TFirst.ShowMe(WhatName: String);
begin
ShowMessage(WhatName);
end;
procedure TForm1.Button1Click(Sender: TObject);
var
TempObj: TSecond;
begin
TempObj := TSecond.Create;
try
TempObj.ShowMe;
finally
FreeandNil(TempObj);
end;
end;
end.