Consider the follow code:
TMyList = class(TList<IMyItem>, IMyList)
Delphi shows me the error:
[DCC Error] test.pas(104): E2003 Undeclared identifier: 'QueryInterface'
Is there a generic list that implements IInterface?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The classes in
Generics.Collectionsdo not implementIInterface. You will have to introduce it yourself in your derived classes and provide the standard implementations. Or find a different, third party, set of container classes to work with.For example:
You can then declare your specialised class:
Remember that you need to treat this class like any other that uses reference counted lifetime management. Only refer to it through interfaces.
You’d really want to do some more work before
TInterfacedList<T>was useful. You’d need to declare anIList<T>which would expose the list capabilities. It would be something like this:You can then simply add
IList<T>to the list of interfaces supported byTInterfacedList<T>and the base classTList<T>would fulfil the interface contract.