Error in my OO Generics design. How do I workaround it?

Posted by John on Stack Overflow See other posts from Stack Overflow or by John
Published on 2010-05-14T14:35:15Z Indexed on 2010/05/14 14:44 UTC
Read the original article Hit count: 240

I get "E2511 Type parameter 'T' must be a class type" on the third class.

type TSomeClass=class
end;

ParentParentClass<T>=class 
end;

ParentClass<T: class> = class(ParentParentClass<T>)
end;

ChildClass<T: TSomeClass> = class(ParentClass<T>)
end;

I'm trying to write a lite Generic Array wrapper for any data type(ParentParentClass) ,but because I'm unable to free type idenitifiers( if T is TObject then Tobject(T).Free) , I created the second class, which is useful for class types, so I can free the objects.

The third class is where I use my wrapper, but the compiler throws that error. How do I make it compile?

© Stack Overflow or respective owner

Related posts about delphi

Related posts about generics