Overloading same operator multiple times

Hi, I just wanted to know how overloading same operator multiple times works and how does the compiler know which overloaded definition is called in.
P.S: Couldn't find anything on google.

Thank you!
Last edited on
how overloading same operator multiple times works
As with any function. Operators are just syntax sugar for function calls.

So if you have something like
1
2
3
foo x;
bar y;
x + y;

Compiler would look for function named operator+ which can take arguments of type foo and bar.
An overloaded operator is a function (albeit with a special syntax).
The rules for function overload resolution apply.

See: http://en.cppreference.com/w/cpp/language/overload_resolution
Note: see 'Call to an overloaded operator' on how the set of candidate functions is formed.
Last edited on
@JLBorges: you have a stray apostrophe at the end of the link.
Thanks. Removing it now.
Thank You very much!
Topic archived. No new replies allowed.