Could I please ask that the doc page for the Ptr keyword be amended to explicitly mention UDTs as an allowable data type, perhaps with an example?
https://www.freebasic.net/wiki/KeyPgPtr
Pointers for UDTs
Re: Pointers for UDTs
Done:
KeyPgPtr → fxm [this modifier can also be applied to UDTs]
KeyPgPtr → fxm [this modifier can also be applied to UDTs]
Re: Pointers for UDTs
Ah, too late. I was preparing this example:
Code: Select all
'Example: Pointers can also be used with user defined types
Type complex_number
As Single real, imaginary
End Type
Dim As complex_number cn1 = (2.1, -3.4)
Dim As complex_number Ptr pCn = Varptr(cn1)
Print pCn->real
Print (*pCn).imaginary
Re: Pointers for UDTs
Wow, that was quick. :-)