But every operation that returns an object, that object is assumed to be assignable (which I assume to be "OO-101"), thus being fit for being taken as an L-value - and that's where the conundrum starts.and that should have been
every operation that returns a non-const object- maybe 'constness' could be the key to that very conundrum here?
From your remark, I got the impression that function returned values are temporary values which are also lvalues. Could you please show me in the C++ standard where this is and why it is necessary? Is it so that we can have statements like: foo() = some-value; ?
There appears to be a difference between temporary values generated from User Defined Types and Built-In Types, as noted in this program:
Open in new window
The line b1 = b2.sumT(12); has the compiler error: lvalue required as left operand of assignment. When commented out, the program gives the expected result: 125.Why should it work for UDT, but not for Built-In-Type?