 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
The
subscript operator should be overloaded as a
|
|
|
|
member;
the first operand must be an object of the class
|
|
|
| • |
To
be consistent, the second operand should be an integer
|
|
|
|
index.
Passed by value as it isn’t changed by the operator.
|
|
| • |
Since
the first operand is not modified (i.e., the current
|
|
|
|
object
is not modified), it should be specified as a
|
|
|
|
constant
member -- although exceptions are common.
|
|
|
| • |
The
residual value should be the data type of the
|
|
|
“element”
of the “array” being indexed, by reference.
|
|
|
| • |
The
residual value is an lvalue -- not an rvalue!
|
|