[fpc-pascal] Type-casting a class variable
Adriaan van Os
adriaan at adriaan.biz
Wed May 1 16:28:12 CEST 2024
Suppose I have a
var myClass: TClass
and (for example) a
class function TWindow.CreateNewWindow( ....)
Now I want to call CreateNewWindow for var myClass. Of course, depending on the class,
CreateNewWindow will behave different. Type-casting myClass to TWindow crashes (in my setup). And
even if it worked, wouldn't it loose the class information ?
Of course, by adding an extra parameter of type TClass to CreateNewWindow, the issue can be solved.
But that's far from elegant.
How to solve this ? Anything I missed ?
Regards,
Adriaan van Os
More information about the fpc-pascal
mailing list