Win64上的接口委托

11

文档显示,只有 Win32 系统支持使用接口委托。目前我无法进行测试,这是文档错误还是 64 位编译器已经取消了接口委托功能呢?

1个回答

9
这是一份文档错误。在Win64下,以下蜂鸣声会响起:
program Win64delegatedInterfaces;

{$APPTYPE CONSOLE}

uses
  SysUtils;

type
  IIntf = interface
    procedure Foo;
  end;

  TMyClass = class(TObject, IIntf)
    FIntf: IIntf;
    property Intf: IIntf read FIntf implements IIntf;
  end;

  TMyOtherClass = class(TInterfacedObject, IIntf)
    procedure Foo;
  end;

var
  MyClass: TMyClass;
  Intf: IIntf;

procedure TMyOtherClass.Foo;
begin
  Beep;
end;

begin
  MyClass := TMyClass.Create;
  MyClass.FIntf := TMyOtherClass.Create;
  Intf := MyClass;
  Intf.Foo;
end.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接