Namespaces
Variants
Views
Actions

Member access operators

From cppreference.com
< c‎ | language
Revision as of 07:28, 26 October 2012 by OrangeBuzzard (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Member access operators allow access to the members of their operands.


Operator Operator name Example Description
[] array subscript a[b] access the bth element of array a
* pointer dereference *a dereference the pointer a to access the data it points to
& address of &a the address of a
. struct member a.b access member b of struct a
-> struct member of pointer to struct a->b access member b of struct pointed to by a

equivalent of first dereferencing the pointer to the struct a then accessing member b:

(*a).b

[edit] See Also

Common operators
assignment increment
decrement
arithmetic logical comparison member
access
other

a = b
a += b
a -= b
a *= b
a /= b
a %= b
a &= b
a |= b
a ^= b
a <<= b
a >>= b

++a
--a
a++
a--

+a
-a
a + b
a - b
a * b
a / b
a % b
~a
a & b
a | b
a ^ b
a << b
a >> b

!a
a && b
a || b

a == b
a != b
a < b
a > b
a <= b
a >= b

a[b]
*a
&a
a->b
a.b

a(...)
a, b
(type) a
? :
sizeof
_Alignof
(since C11)