Abstraction Mechanisms, Part 1
- slide 35 : 36
Operator overloading
C++ supports comprehensive overloading of existing operators
The C++ Programming Language
: Page 261 - ...
Restrictions on operator overloading
It is not possible to invent new operator symbols.
The associativity and precedence of the predefined rules of predefined operators apply
The following operators cannot be overloaded:
::
(scope),
.
(member selection),
.*
(member selection through pointer),
?:
(conditional, ternary),
sizeof
,
typeid
.
At least one operand must be of a user-defined type
If the left operand is of user-defined type, the operator may be defined as a member function
If the left operand is a predefined type, the operator must be a non-member function
For some operators, special rules and interpretations apply
The C++ Programming Language
: Page 286 - ...