[fpc-pascal] Type-casting a class variable

Martin Frb lazarus at mfriebe.de
Thu May 2 09:06:56 CEST 2024


On 02/05/2024 08:32, Adriaan van Os via fpc-pascal wrote:
> Martin Frb via fpc-pascal wrote:
>
>> Silly question, but did you assign the value to the variable?
>>
>> myClass := TWindow;
>
> That's what I did.
>
>> TWindow(myClass).CreateNewWindow;
>
> And this is what crashes. I can report this, if the type-cast is 
> supposed to work.

My example (2nd part of it) was actually wrong.

It was mentioned before

On 01/05/2024 19:43, Jean SUZINEAU via fpc-pascal wrote:
> I didn't tested but I imagine it could be done with something like this ?
>
> type
>        TWindow_Class= class of TWindow;
> begin
>           ...
>           (myClass as TWindow_Class).CreateNewWindow( ....);

It must be cast to another "class of"


More information about the fpc-pascal mailing list