What “type of” declaration represents in Delphi and how can it be used

前端 未结 3 1224
死守一世寂寞
死守一世寂寞 2021-02-01 04:23

There is some strange code in Datasnap.DSReflect unit

  TDSAdapterClassType = type of TDSAdapterClass;

  TDSAdapterClass = class(TPersistent)
  pri         


        
3条回答
  •  灰色年华
    2021-02-01 05:16

    In Delphi.Net we have the following definitions in SysUtils:

    type
      TInterfaceRef = type of interface;
    
      function Supports(const Instance: TObject; const IID: TInterfaceRef): Boolean; overload; inline;
    

    So it was some kind of replacement for class of that can be used for interface types.

    The following document mentions a "Type reference syntax (type of Interface)": http://edn.embarcadero.com/article/29780

    Here's some more info: http://hallvards.blogspot.de/2004/11/object-to-interface-casts.html

提交回复
热议问题