
please wait
(*x).y
will de-reference x
, and then access it's member variable called y
;*x.y
doesn't have any parentheses. So C++ looks at its precedence rules. .
has precedence over *
, so it will do (x.y)
and then de-reference that result.(*x)
will de-reference x
, and .y
will access the member variable y
; x->y
is just "syntactic sugar" for (*x).y
a.b.c=num;
, both of those operators are the same..
goes left-to-right when there are multiples of them right next to each other.a
has a member variable b
and b
has a member variable c
. It first accesses a.b, then accesses b.c.
and ->
have the same precedence, and there are not parentheses or anything to tell which one to do first, so it is done lef-to-right.a.b.c=num;
, all 3 are objects/structures.(*d).e->f = 10;
, d and e are pointers, and f is a pointer.
|
|