Hacker News new | ask | show | jobs
by vardump 4223 days ago
Operator overloading is a syntactic sugar trick that hides the real method call. Nothing more, nothing less.

It's useful in vector math, complex number math, matrix math.

1 comments

Operator overloading is useful for a lot more than just math. Overloading * and -> is useful for pointer-like types. Overloading () is useful for function-like types. Overloading [] is useful for collections and overloading ++ and -- is useful for iterators.
The overloading of (), [], and the like is used but it's not necessary. They could have been other named overloaded functions.