My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
I believe the return value from a constructor is an lvalue.
Code:class T {}; int main() { T t; T() = t; }
Thanks iMalc,
1.
Why reference to const is not a lvalue? I think the rule to judge lvalue and rvalue is whether or not it is addressable/nameable other than whether or no it could be on left side or right side of =.
2.
I mean the object instance returned by contructor... Any comments?
regards,
George
What you say is true. However, before the const keyword was introduced to C, an lvalue was defined as anything that could appear on the left hand side of an assignment. Since const was added to the language, that notion became a "modifiable lvalue".
lvalues are values that have addresses, meaning they are variables or dereferenced references to a certain memory location. In other words, it designates (refers to, addresses, allows examination of) an object. A modifiable lvalue is both addressable and assignable. An unmodifiable lvalue is addressable, but not assignable.
An rvalue is a value that is stored at a specific memory location (but not necessarily addressable). Any lvalue can be an rvalue (or implicitly converted to an rvalue -- meaning its value is fetched). However, not all rvalues are lvalues.
The rvalue to lvalue conversion essentially allows assignment of the value of the rvalue into an lvalue.
Last edited by grumpy; 02-29-2008 at 04:59 AM.