Item 26. Operator Function Lookup

Sometimes it looks like a member operator function overloads a non-member operator, but this is not the case. It’s not overloading; it’s just a different lookup algorithm. Consider the following class that overloads an operator as a member function:

image

We can call an overloaded operator function with either infix or function call syntax:

image

When we use the function call syntax, the usual lookup rules apply (see Member Function Lookup [24, 87]), and the call b.operator %(c) is treated in the same way as the similar ...

Get C++ Common Knowledge: Essential Intermediate Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.