B
blue_morning
Unregistered / Unconfirmed
GUEST, unregistred user!
请看父类中的:
protected
function SaveDataQuery: Longint
virtual;
到了子类中:
public
function SaveDataQuery: Longint
override;
使用Ctrl+Shift+C自动生成的代码中,没有inherited关键字,而procedure关键字的虚方法就能产生inherited关键字。 请参看其它两个procedrue的虚方法
为什么?
父类:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
protected
function SaveDataQuery: Longint
virtual;
procedure Test
virtual;
procedure HaveParam(var UserSelect: LongInt)
virtual;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.HaveParam(var UserSelect: Integer);
begin
UserSelect := ID_YES;
ShowMessage('TForm1.HaveParam');
end;
function TForm1.SaveDataQuery: Longint;
begin
Result := ID_YES;
ShowMessage('TForm1.SaveDataQuery: Longint');
end;
procedure TForm1.Test;
begin
ShowMessage('Test');
end;
end.
子类:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unit1, StdCtrls;
type
TForm2 = class(TForm1)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
function SaveDataQuery: Longint
override;
procedure Test
override;
procedure HaveParam(var UserSelect: LongInt)
override;
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
{ TForm2 }
procedure TForm2.Button1Click(Sender: TObject);
var
i: Longint;
begin
HaveParam(i)
end;
procedure TForm2.HaveParam(var UserSelect: Integer);
begin
inherited;
end;
function TForm2.SaveDataQuery: Longint;
begin
end;
procedure TForm2.Test;
begin
inherited;
end;
end.
protected
function SaveDataQuery: Longint
virtual;
到了子类中:
public
function SaveDataQuery: Longint
override;
使用Ctrl+Shift+C自动生成的代码中,没有inherited关键字,而procedure关键字的虚方法就能产生inherited关键字。 请参看其它两个procedrue的虚方法
为什么?
父类:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs;
type
TForm1 = class(TForm)
private
{ Private declarations }
protected
function SaveDataQuery: Longint
virtual;
procedure Test
virtual;
procedure HaveParam(var UserSelect: LongInt)
virtual;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TForm1 }
procedure TForm1.HaveParam(var UserSelect: Integer);
begin
UserSelect := ID_YES;
ShowMessage('TForm1.HaveParam');
end;
function TForm1.SaveDataQuery: Longint;
begin
Result := ID_YES;
ShowMessage('TForm1.SaveDataQuery: Longint');
end;
procedure TForm1.Test;
begin
ShowMessage('Test');
end;
end.
子类:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Unit1, StdCtrls;
type
TForm2 = class(TForm1)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
function SaveDataQuery: Longint
override;
procedure Test
override;
procedure HaveParam(var UserSelect: LongInt)
override;
end;
var
Form2: TForm2;
implementation
{$R *.dfm}
{ TForm2 }
procedure TForm2.Button1Click(Sender: TObject);
var
i: Longint;
begin
HaveParam(i)
end;
procedure TForm2.HaveParam(var UserSelect: Integer);
begin
inherited;
end;
function TForm2.SaveDataQuery: Longint;
begin
end;
procedure TForm2.Test;
begin
inherited;
end;
end.