Error in my OO Generics design. How do I workaround it?
- by John
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?