Operator Overloading
What is operator overloading?
Defining certain operators as your own custom Functions / Methods
Operator Overloading
What are the two options for operator overloading?
A method and a function
Operator Overloading
What are the 3 rules of Operator Overloading?
Operator Overloading
What are the characteristics of using a Function to overload and operator?
Operator Overloading
What are the characteristics of using a Method to overload and operator?
Operator Overloading
When would you use a Function to overload an operator?
When the left side of the operator is a primitive or pre-defined type.
Operator Overloading
When would you use a Method to overload and operator?
When the left side of the operator can be represented by the ‘This’ keyword.
Operator Overloading
What is the syntax for using a Function to overload an operator?
return_type operator (const type& lhs, const type& rhs) {
…
}
Operator Overloading
What is meant by operator overloading not being mutable?
Operator Overloading
When overloading an operator, why are function arguments const?
Because an operator should not change its operands, but return a new object.
Operator Overloading
What are the main operators that cannot be overloaded?