I am trying to declare a user list of interfaces from which I want to inherit in order to get a list of specific interfaces (I know about IInterfaceList, this is just an example). I use Delphi 2007, so I do not have access to the actual generics (sorry for me).
Here is a simplified example:
ICustomInterfaceList = interface procedure Add(AInterface: IInterface); function GetFirst: IInterface; end; TCustomInterfaceList = class(TInterfacedObject, ICustomInterfaceList) public procedure Add(AInterface: IInterface); function GetFirst: IInterface; end; ISpecificInterface = interface(IInterface) end; ISpecificInterfaceList = interface(ICustomInterfaceList) function GetFirst: ISpecificInterface; end; TSpecificInterfaceList = class(TCustomInterfaceList, ISpecificInterfaceList) public function GetFirst: ISpecificInterface; end;
TSpecificInterfaceList will not compile:
E2211 GetFirst declaration differs from declaration in interface ISpecificInterfaceList
I suppose that theoretically I can use TCustomInterfaceList, but I do not want to throw GetFirst every time I use it. My goal is to have a specific class that inherits the behavior of the base class and wraps "GetFirst".
How can i achieve this?
Thanks!
source share