D
devecom
Unregistered / Unconfirmed
GUEST, unregistred user!
具体参考: http://www.csdn.net/expert/topic/328/328923.shtm
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
IX = interface
['{41AB2EA3-E950-4285-BF3C-2F07ECF5DDF4}']
procedure xx;
end;
IY = interface
['{70FBB89C-6528-4A40-A624-432F61D98B03}']
procedure yy;
end;
TXY = class
a: IX;
b: IY;
public
procedure xy;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TXY }
procedure TXY.xy;
begin
a.xx
//没错
showmessage('a');
b.yy
//错了, 为什么?
end;
procedure TForm1.Button1Click(Sender: TObject);
var c: TXY;
begin
c.xy
//按下之后的事件在上面的程序有问题。
end;
end.
想不通为什么在b.yy会出错,而a.xx不出错
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
IX = interface
['{41AB2EA3-E950-4285-BF3C-2F07ECF5DDF4}']
procedure xx;
end;
IY = interface
['{70FBB89C-6528-4A40-A624-432F61D98B03}']
procedure yy;
end;
TXY = class
a: IX;
b: IY;
public
procedure xy;
end;
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TXY }
procedure TXY.xy;
begin
a.xx
//没错
showmessage('a');
b.yy
//错了, 为什么?
end;
procedure TForm1.Button1Click(Sender: TObject);
var c: TXY;
begin
c.xy
//按下之后的事件在上面的程序有问题。
end;
end.
想不通为什么在b.yy会出错,而a.xx不出错