Wallstreet
asked on
How to add an Interface type to a container
Hello All,
Can anybody tell me how I could add an Object (which has been typecasted to an Interface) in any of Delphi Containers.
The reason I have typecasted to an Interface is, mainly due to multiple inheritance.
I tried to add the object to a TList and to a TObjectList with no success. It says "Incompatible types"
It looks like TList or TObjectList don't like to add anything which has been typecasted to an interface.
Thanks in advance,
Jeewa
Can anybody tell me how I could add an Object (which has been typecasted to an Interface) in any of Delphi Containers.
The reason I have typecasted to an Interface is, mainly due to multiple inheritance.
I tried to add the object to a TList and to a TObjectList with no success. It says "Incompatible types"
It looks like TList or TObjectList don't like to add anything which has been typecasted to an interface.
Thanks in advance,
Jeewa
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you verymuch Ziolko
ASKER
Thank for the insights BorlandMan
WallStreat one more tip if You will try to typecast Interface to pointer You have to call _AddRef after typecast and _Release before destroying interface.
ziolko.
ziolko.
ASKER
Ziolko,
I don't have an immediate need to do that but appreciate you telling me.
Thank You.
Wallstreet
I don't have an immediate need to do that but appreciate you telling me.
Thank You.
Wallstreet
yep.
also, keep in mind that when you add that interface to TInterfacelist that the Interface will not drop out of memory until you delete it from the TInterfaceList.... which is pretty much what you want (right?)
J