Why the compiler is generating the sentence,
Lvalue required. what is the meaning

jonsca commented: Don't bump old threads -1

The standard splits all expressions into 2 broad categories, lvalue and rvalue. The actual definition with-in the standard is rather involved but a simplistic rule of thumb is that an lvalue is an expression that results in a modifiable value where as an rvalue doesn't. Any lvalue can be converted to an rvalue but rvalues can not be converted to lvalues.

l and r stand for left and right colloquially and refer to where the expression can appear in relation to the assignment operator.

lvalue = rvalue - good
rvalue = rvalue - bad

You can assign to an lvalue because it is modifiable, you can not assign to an rvalue because it is not modifiable. Not that you can only assign from an rvalue but because all lvalues can be converted to rvalues that is not an issue. int array[5]; declares an array, and NOT a pointer. An array is an rvalue (where as a pointer is an lvalue) and can not be assigned to. This is one of the differences between arrays and pointers. Because an array is an rvalue array++; produces an error because the ++ operator requires an lvalue.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.