class item {
public:
item& operator=(const item &rh) {
...
...
return *this;
}
};
Is the following signatur
It is not "wrong", but surprising. An assignment evaluates to the target object. That's what the builtin meaning is. If you define it different for your own class, people could become confused.
Example:
int c;
while((c = getchar()) != EOF) {
// ...
}
The assignment to c
returned c
itself and compared it to EOF
afterwards. Users would expect your item
class to behave similar.