Re: returning lvalue in C vs C++



* Kai-Uwe Bux:
* Ben C:

But x is an int, so if f().x = 200 works on that basis, why not g() = 4?

Yup: why not?

Because you can't assign to an rvalue.


I don't know. But for classes, it sure works:
>
struct dummy {

dummy & operator= ( dummy const & other ) {
std::cout << "hello world!\n";
return ( *this );
}
};

But you can call a member function on an rvalue of class type.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
.