Why are they called "primary"? In the order of evaluence they are the first?
C++03
standard defines the expression in chapter 5 (Note 1):An expression is a sequence of operators and operands that specifies a computation.
Then the 5.1 "Primary expressions" defines the list of primary expressions:
(1) primary-expression:
literal this ( expression ) id-expression
My main question is in connection the third point:
( expression )
So, according to the standard, every expression with brackets are primary expressions and they are calculated firstly. It looks logical, and gives an exact explanation of the behavior of brackets in C++ expressions (precedence).
So this means that for example
(variable + 10)
is a primary expression.
var = (variable + 10) * 3
and according to my theory, it looks logic, BUT from other sources I know
(variable + 10)
is NOT a primary expression, but WHY? I don't understand, however the standard defines the
(expression)
as a primary expression.
Please, help me because I can't. Thank you very much, and sorry for my bad English. Hi.
(variable + 10)
is not a primary expression? And "primary expression" doesn't neccesarily mean it gets evaluated first. – Glyptographint x = (1+5) - ++i;
++i
might as well be evaluated first, even though it's a unary expression, not primary. And whoever said (variable + 10) is not a primary expression is plain wrong. – Glyptograph