Am 26.02.2014 16:11, schrieb silvioprog:
Hello,

I'm trying to add new features in a third generic type. Please see this simulation below:

  { TThirdGeneric }

  generic TThirdGeneric<T> = class
  private
    FFoo: T;
  public
    procedure Post;
    property Foo: T read FFoo;
  end;

  { TMyGeneric }

  generic TMyGeneric<T> = class(TThirdGeneric)
This must be "class(specialize TThirdGeneric<T>)" (the "T" is the same type parameter as specified for the "TMyGeneric" declaration, so if it would be "TMyGeneric<MyType>" it would need to be "class(specialize TThirdGeneric<MyType>)")
  public
    procedure ConfigureFoo;
  end;

  { TMyClass }

  TMyClass = class(TMyGeneric)
A class parent must always be a specialization as generics are no valid types per se. So here the correct declaration would again be "class(specialize TMyGeneric<WhateverTypeYouNeed>)".
  public
    procedure Post;
  end;
[snip]
Just trying to understand the generics concept correctly. :S

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to