Hacker News new | ask | show | jobs
by SamReidHughes 4223 days ago
Operator overloading is just a function call. Everything you say about overloading an operator could be said about the function call that would replace the overloaded operator. I've never had trouble recognizing that a use of an operator was being done with a non-primitive type, which is the only way the confusion you describe could possibly happen, and the problem you describe has never happened to me while working on C++ code. I don't know why you think it is even plausible.
2 comments

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.

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.
A function call is always a function call, an operator is not. It makes for more opaque code.
Function calls aren't always function calls.