In what ways does an overloaded operator differ from a built-in operator?
Main difference
- An overloaded operator can be called directly as normal function, while a built-in operator cannot.
- Overloaded opereators do not preserve order of evaluation and/or short-circuit evaluation.
Difference about overloaded operator function
- An overloaded operator function must either be a member of a class or have at least one parameter of class type.
- Only part of the existing operators can be overloaded. (We cannot invent new operator symbols.)
In what ways are overloaded operators the same as the built-in operators?
- Overloaded operators can be used as the built-in operators in the same way snytactically.
- Overloaded operators have the same precedence and associativity as the corresponding built-in operators.