[fpc-pascal] Inheriting from generics specialized classes

Juha Manninen juha.manninen62 at gmail.com
Thu Nov 24 17:00:00 CET 2011


... Sorry, forgot subject first....

I try to learn to use generics properly.
First, this is a class definition without generics:

  TMyDerived = class(TObjectList)
  private
    MyInt: integer;
  public
    constructor Create(FreeObjects: Boolean=True);
  end;

It works. Now I try to derive a class with generics:

  TMyGen = specialize TFPGObjectList<TControl>;

  TMyDerived = class(TMyGen)
  private
    MyInt: integer;
  public
    constructor Create(FreeObjects: Boolean=True);
  end;

It says:
 unit1.pas(40,24) Error: Duplicate identifier "FreeObjects"

Why? If I change "FreeObjects" to "aFreeObjects" then it works. Again why?

Is it even ok to derive classes from specialized classes like that?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20111124/3715f402/attachment.html>


More information about the fpc-pascal mailing list