I came across this article. And its example says:
int main()
{
int i, j, *p;
// Correct usage: the variable i is an lvalue and the literal 7 is a prvalue.
i = 7;
...
}
I wonder why literal 7 is a prvalue.
The standard [7.2.1.1.2] says:
A prvalue is an expression whose evaluation
initializes an object or a bit-field, or computes the value of an
operand of an operator, as specified by the context in which it
appears, or an expression that has type cv void.
The expression 7
itself doesn't initializes an object nor a bit-field, nor computes the value of an operand of an operator as 7
itself doesn't have an operator.
Maybe I don't interpret the standard correctly.
Aucun commentaire:
Enregistrer un commentaire