Which of these five statements about lvalues ​​is true?

I am doing the following puzzle. Maybi someone can check if I pick the right answer correctly. Take a look.

Which of the following is a true lvalue statement?

1 The l value is the result of an arithmetic operation involving long int values.

2 All lvalues ​​can be used on the right side of an assignment statement.

3 The l value is, by definition, the value that appears on the rightmost side of the assignment expression.

4 By definition, an lvalue is a memory space that indirectly refers to a pointer.

5 lvalue is any number that may appear on the left side of the shift operator.

Ok, an lvalue is a reference to an object in memory. So at first glance, I thought of the 4th answer, but now it seems to be wrong since the lvalue is not the treasure itself (and answer 4 implies it). # I think answer 2 is correct , since lvalues ​​can be used on the left and right side of the assignment operator. What do you think?

+3


source to share


1 answer


I think answer 2 is correct as lvalues ​​can be used on the left and right side of the assignment operator

Yes, this is true for this exact reason.

Problem with other statements:

1) lvalue is the result of an arithmetic operation involving long int values.

Not. To be long int

or not has nothing to do with lvalues. (long int)42

has a type long int

, but it is not an lvalue.

3) The value of l, by definition, has the value indicated on the right-most side of the assignment operator.



Not. I don't know if it has any special name, but this is not an lvalue definition for sure.

4) By definition, an lvalue is a memory space that indirectly refers to a pointer.

Not. You don't need any pointers for this. As in int i = 1337;

, i

is the value of l. However, there are no pointers in the code at all.

5) lvalue is any number that may appear on the left side of the shift operator.

Not. On the surface, lvalues ​​are more about being modifiable in some way (assignment to a variable or an array member), so this statement will be closer to true if shift operator

it reads instead assignment operator

. However, not all lvalues ​​can be changed (for example, a constant is an lvalue, but it cannot be changed after it has been initialized).

+4


source







All Articles