by jpdoctor · 14y ago · 0 comments
An lvalue (locator value) represents an object that occupies some identifiable location in memory (i.e. has an address).
rvalues are defined by exclusion, by saying that every expression is either an lvalue or an rvalue.
So a pointer represents "an object that occupies some identifiable location in memory", meeting his definition of lvalue, and yet is a perfectly valid rvalue.
I sentence this person to be a teaching assistant for one term.
Edit: I love the first two replies to this comment:
1. No, lvalues are never rvalues by definition.
2. all lvalues are rvalues,
oh, maybe you meant an rvalue that happens to be a pointer? still makes sense, the pointer is not the same as what it points to.
[In light of Sharlin's comment, I should edit this to say that "lvalues are rvalues" is shorthand for "convertible to", the significance of the difference being what you make of it.]
I wonder if teaching from the standard is a better way of approaching this, ie: start with the standard, then just explain what it means.