I'm thinking then that answer 2 is correct as lvalues can be used on left and right hand side of the assignment operator
Yes, this one is true, for this exact reason.
The problem with the other statements:
1) An lvalue is the result of an arithmetic operation involving quantities of type long int.
No. Being long int
or not does not have anything to do with lvalues. (long int)42
is of type long int
, yet it's not an lvalue.
3) An lvalue is, by definition, the value appearing on the rightmost side of an assignment statement.
No. I don't know if that has any special name, but that's not the definition of lvalue for sure.
4) By definition, an lvalue is the storage space indirectly referenced by a pointer.
No. You don't need any pointers for that. As in int i = 1337;
, i
is an lvalue. No pointers in the code whatsoever, though.
5) An lvalue is any quantity capable of appearing on the left side of a shift operator.
No. At first glance, lvalues have more to do with the ability to being modified in some way (assignment to a variable or to a member of an array), so this statement would be closer to true if instead of shift operator
it read assignment operator
. However, not all lvalues can be modified (for example a constant is an lvalue, yet it can't be modified after initializing it).