Pointers for UDTs

Forum for discussion about the documentation project.
fzabkar
Posts: 79
Joined: Sep 29, 2018 2:52

Pointers for UDTs

Postby fzabkar » Feb 22, 2021 20:28

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

Re: Pointers for UDTs

Postby fxm » Feb 22, 2021 21:20

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

Re: Pointers for UDTs

Postby badidea » Feb 22, 2021 21:26

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: 79
Joined: Sep 29, 2018 2:52

Re: Pointers for UDTs

Postby fzabkar » Feb 22, 2021 21:34

Wow, that was quick. :-)

Return to “Documentation”

Who is online

Users browsing this forum: No registered users and 5 guests