代码之家  ›  专栏  ›  技术社区  ›  Christino

Delphi 2010和泛型

  •  1
  • Christino  · 技术社区  · 8 年前

    我正在尝试做以下事情:

    type
      IExemplo<Generic> = interface
        function GetGenerico: Generic;    
      end;
    
      TClassA<Generic> = class(TComponent, IExemplo<Generic>)
        function GetGenerico: Generic; virtual;
        function GetInterface: IExemplo<Generic>; virtual;
      end;
    
      TClassB = class(TClassA<string>)
        function GetGenerico: string; override;
        function GetInterface: IExemplo<string>; override;
      end;
    

    但是,在排队的时候

    function GetInterface: IExemplo<string>; override;
    

    我收到一个语法错误。

    我的目标是 TClassB

    1 回复  |  直到 8 年前
        1
  •  4
  •   David Heffernan    8 年前

    此代码有效,可在Delphi的更高版本中编译。实际上,它是用Delphi 2010为我编译的,所以我想知道您是否还没有安装 all the updates that are available for Delphi 2010 .