N
njchj
Unregistered / Unconfirmed
GUEST, unregistred user!
关于接口--我百想不得其解 100分相送
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ITankData, StdCtrls, ExtCtrls;
type
ITank = interface
['{819F3D2D-4B86-4333-8BAE-CA538947EF6F}']
procedure Init;
end;
TFrame2 = class(TFrame,ITank)
LabeledEdit1: TLabeledEdit;
private
{ Private declarations }
public
{ Public declarations }
procedure Init;
end;
implementation
{$R *.dfm}
procedure TFrame2.Init;
begin
LabeledEdit1.Text :='test';
end;
end.
//=============================================
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Unit2 ;
type
TForm1 = class(TForm)
TFrame21: TFrame2;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses ITankData;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var list : TList;
begin
list := TList.create;
list.Add(TFrame21);
Itank(List.Items[0]).init;
end;
end.
在Unit1中Itank(List.Items[0]).init这句无法通过,而用数组却正常。
不知道为何。我用的是delphi7
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,ITankData, StdCtrls, ExtCtrls;
type
ITank = interface
['{819F3D2D-4B86-4333-8BAE-CA538947EF6F}']
procedure Init;
end;
TFrame2 = class(TFrame,ITank)
LabeledEdit1: TLabeledEdit;
private
{ Private declarations }
public
{ Public declarations }
procedure Init;
end;
implementation
{$R *.dfm}
procedure TFrame2.Init;
begin
LabeledEdit1.Text :='test';
end;
end.
//=============================================
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, Unit2 ;
type
TForm1 = class(TForm)
TFrame21: TFrame2;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses ITankData;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var list : TList;
begin
list := TList.create;
list.Add(TFrame21);
Itank(List.Items[0]).init;
end;
end.
在Unit1中Itank(List.Items[0]).init这句无法通过,而用数组却正常。
不知道为何。我用的是delphi7