如何从具有受保护数据类型的类继承?

Ste*_*han 3 delphi inheritance protected

我有一个带有内部受保护类的基本泛型类.如何从基类继承并访问受保护的内部类?

作为示例,此代码将无法编译:

unit uFoo;

interface

type

  TFoo<T> = class
  protected
    type
      TFooProtected = class

      end;
  end;

  TFoo2<T> = class(TFoo<T>)
  protected
    item: TFooProtected;
  end;
Run Code Online (Sandbox Code Playgroud)

Rem*_*eau 6

像这样:

type
  TFoo<T> = class
  protected
    type
      TFooProtected = class
      end;
  end;

  TFoo2<T> = class(TFoo<T>)
  protected
    item: TFoo<T>.TFooProtected;
  end;
Run Code Online (Sandbox Code Playgroud)

请注意,这与泛型无关.它适用于在内部声明类型的任何类.