In the following case,
int i = 0;
int j = 42;
i = j++;
I know ++
is posfix operator, So, is j
a posfix expression or should you say j++
is posfix expression ?
Syntactically, both j
and j++
are postfix-expressions.
See the grammar in section 5.2 of the C++ 2003 standard:
postfix-expression:
primary-expression
...
postfix-expression ++
( j
is also a primary-expression; j++
is not.)
The fact that a primary-expression is a kind of postfix-expression (even if it doesn't contain a postfix operator) is mostly a matter of convenience for defining the language syntax. There's not much point in referring to j
as a postfix-expression unless you're talking about parsing C++ (or C) source code.
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.