 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| |
If
the + operator is overloaded, we should also overload
|
|
|
the
+= operator
|
|
|
| |
The
+ operator can take either a string or a char * as the
|
|
|
first
or second operands, so we will overload it as a non-
|
|
member
friend and support the following:
|
|
|
|
|
string
+ char *, char * + string, string + string
|
|
|
| |
For
the += operator, the first operand must be a string
|
|
|
object,
so we will overload it as a member
|
|
|
| |
The
+ operator results in a string as an rvalue temp
|
|
|
| |
The
+= operator results in a string as an lvalue
|
|
|
| |
The
+ operator doesnt modify either operand, so string
|
|
|
object
should be passed as constant references
|
|