The example:
++structure.field;
increments field
instead of giving "wrong type argument to increment" compiler error, although ++ and. operators are equaly hierarchized ergo: should've been executed from left to right.
Am I missing something here?
Prefix and postfix ++
have different precedence. .
has the higher precedence than the prefix increment operator, as seen on cppreference.com .
.
and postfix increment have the same precedence. If you wrote structure.field++
then they'd have the same precedence and associativity would kick in to resolve the ambiguity as (structure.field)++
rather than structure.(field++)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.