Alex Rivera | Logout

Is a dereferenced pointer a valid lvalue?

Asked 2011-01-23T12:42:25.347
25

Assuming the definition:

int i  = 10;
int *p = &i;

Why is *p a valid lvalue here:

*p+=10; 

Shouldn't *p evaluate to the value of the int stored at &i, ie. 10, and hence generate a "Not an lvalue" error?

Edit
Report

1 Answer

15

An lvalue is an expression that refers to a region of storage that can be manipulated.

*p is such an expression that refers to a region of storage. This is different than say 10+=10; because 10 doesn't refer to a region of storage like a variable would.

answered 2011-01-24T19:58:38.580

Your Answer