Pointers for UDTs

Forum for discussion about the documentation project.
Post Reply
fzabkar
Posts: 154
Joined: Sep 29, 2018 2:52
Location: Australia

Pointers for UDTs

Post by fzabkar »

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
fxm
Moderator
Posts: 12081
Joined: Apr 22, 2009 12:46
Location: Paris suburbs, FRANCE

Re: Pointers for UDTs

Post by fxm »

Done:
KeyPgPtr → fxm [this modifier can also be applied to UDTs]
badidea
Posts: 2586
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: Pointers for UDTs

Post by badidea »

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
fzabkar
Posts: 154
Joined: Sep 29, 2018 2:52
Location: Australia

Re: Pointers for UDTs

Post by fzabkar »

Wow, that was quick. :-)
Post Reply