Arithmetic Operator Overloading
Operator overloading enables custom types to use operator syntax like +, -, *. Overloading is implemented by defining operator func in a class, struct, or extend.
The code on the right defines a Point class representing a 2D point, overloading the binary + operator (point addition) and unary - operator (negation). After overloading, expressions like p1 + p2 and -p are natural and intuitive, consistent with built-in numeric types.
Unary operator functions have no parameters, while binary operator functions have one parameter representing the right operand. Operators don't change their inherent precedence and associativity—multiplication still takes precedence over addition.
static; they are essentially instance member functions that can access the current object using this.Try adding a * operator to implement multiplication between a point and a scalar.