简体   繁体   中英

Interface delegation on Win64

Documentation states that interface delegation is available for Win32 only. Currently I can't test it, is it documentation bug or interface delegation is discontinued in 64-bit compiler?

It's a documentation bug. The following beeps under 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM