【问题标题】:Interface delegation on Win64Win64 上的接口委托
【发布时间】:2012-02-11 17:28:30
【问题描述】:

Documentation 声明接口委托仅适用于 Win32。目前我无法测试它,是文档错误还是接口委托在 64 位编译器中已停止?

【问题讨论】:

    标签: delphi interface delphi-xe2 delegation


    【解决方案1】:

    这是一个文档错误。 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.
    

    【讨论】:

      猜你喜欢
      • 2012-07-05
      • 2014-08-18
      • 2021-02-20
      • 2012-01-31
      • 2011-02-10
      • 1970-01-01
      • 2010-10-07
      • 2020-08-22
      • 1970-01-01
      相关资源
      最近更新 更多