class item {
public:
item& operator=(const item &rh) {
...
...
return *this;
}
};
La seguente firma è errata?Perché l'operatore di assegnazione sovraccaricata restituisce il riferimento alla classe?
void operator=(const item &rh);
item a, b;
a = b; // equivalent to a.operator=(b); so there is no need to return this.
e fondamentalmente questo è ciò che i tipi incorporati fanno –