Win64上的接口委派

klu*_*udg 11 delphi interface delegation delphi-xe2

文档指出接口委派仅适用于Win32.目前我无法测试它,是否在64位编译器中停止了文档错误或接口委托?

Dav*_*nan 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.
Run Code Online (Sandbox Code Playgroud)