nWhenever we overload the arithmetic or bitwise operators, we should also overload the corresponding compound assignment operators.
nWhen we do, it is tempting to reuse the overloaded arithmetic or bitwise operators to implement the compound assignment operator.
n
n//assumes the + operator
is overloaded for string class
ninline string
&string::operator+=(char * s) {
n *this
= *this + s; //concatenate a
literal
n return (*this); //return modified current object
n}
nDon’t Program this Way!