Show: Object Pascal C++
Display Preferences

-> (indirect Member Selector)

From Appmethod Topics
Jump to: navigation, search

Go Up to Postfix Expression Operators Index


Syntax

postfix-expression -> identifier

postfix-expression must be of type pointer to structure or pointer to union.

identifier must be the name of a member of that structure or union type.

The expression designates a member of a structure or union object. The value of the expression is the value of the selected member it will be an lvalue if and only if the postfix expression is an lvalue.

Remarks

You use the selection operator -> to access structure and union members.

Suppose that the object s is of struct type S and sptr is a pointer to s. Then, if m is a member identifier of type M declared in S, this expression:

sptr->m

is of type M, and represents the member object m in s.

The expression

s->sptr

is a convenient synonym for (*sptr).m.

Personal tools
In other languages