[fpc-devel] problem with "is" operator

Linuxer Wang linuxerwang at gmail.com
Sun Apr 17 21:01:36 CEST 2005


Can anybody tell me how can I know which specific type an instance of
class is? The "is" operator seems weird when interface is used.

Suppose TMyInterface is a interface, and classes TCircle and TSquar
both implements TMyInterface, and inst:TMyInterface, inst :=
TCircle.Create. How can I know which instance is inst? The following
code can not even compile:

if inst is TCircle then ...

class type expected, but got "TMyInterface"
Incompatible type for arg no. 2: Got "TMyInterface", expected "TObject"


More information about the fpc-devel mailing list