2008/5/18 Marc Santhoff <[EMAIL PROTECTED]>:
> When using a cast from an interface to an object the compiler warns
> about the class types "TObject" and "IObserver" not being related.
>
> Since an implementor of in interface always will be a class type and any
> class type at least inherits from TObject, I assume it is okay?
>
> Is there a better method of handling this case?

Casting of Interfaces has always been known to me as a big NO-NO.  I
believe it's got something to do with how they are represented in the
VMT or method table or something like that. I don't know the compiler
internals. Why not simply use a InterfaceList or a generic Pointer
list (as to not increment the interface reference counter). You can
then add them to the list without having to cast to TObject.


Regards,
 - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to