Skip to content

Operator Pointer to Member Access

Paul Squires edited this page Sep 19, 2026 · 1 revision

Home › Operators › Operator -> (Pointer To Member Access)

Operator -> (Pointer To Member Access)

Returns a reference to a member from a pointer to an object

Syntax

Declare Operator -> ( ByRef lhs As T Ptr ) ByRef As U

Parameters

  • lhs
  • T
  • rhs
  • U
  • rhs

Description

Operator -> (Pointer to member access) returns a reference to a member of an object through a pointer to that object. It has the effect of dereferencing a pointer to an object, then using Operator . (Member Access). For example, "p->member" is equivalent to "x.member", if x is an object of user-defined type and p is a pointer to an object of the same type. "p->member" is equivalent to "(*p).member".

This operator can be overloaded for user-defined types.

Return Value

Returns a reference to the member specified by rhs.

Remarks

Usage

result = lhs -> rhs

Dialect Differences

  • Not available in the -lang qb dialect.

Differences from QB

  • New to FreeBASIC

See also

Examples

Type rect

    x As Integer

    y As Integer

End Type

Dim r As rect

Dim rp As rect Pointer = @r

rp->x = 4

rp->y = 2

Print "x = " & rp->x & ", y = " & rp->y

Sleep

Category: Operators
Kind: operator


Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.

Clone this wiki locally