Item 24. Member Function Lookup

When you call a member function, there are three steps involved. First, the compiler looks up the name of the function. Second, it chooses the best matching function from the available candidates. Third, it checks that you have access to the matched function. That’s it. Admittedly, each of these steps (especially the first two; see Argument Dependent Lookup [25, 89] and Operator Function Lookup [26, 91]) can be complex, but the overall function matching mechanism is as simple as one, two, three.

Most errors related to function matching stem not from misunderstanding the compiler’s complex name lookup and overloaded function matching algorithms but from misunderstanding the simple, sequential nature of these three ...

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.