6.3. Overloading Resolution

When users call overloaded functions with arguments, it's not always possible to call them with data types that exactly match one of the overloaded signatures. To avoid compilation errors and ambiguities, you need to know how the compiler promotes data types, performs conversions (trivial, standard, or user-defined), and determines which “best-fit” function to call. This section investigates how the compiler resolves overloaded signatures for single and multiple arguments. We'll start with single argument matching and then generalize the rules for multiple arguments.

Single Argument Matching

The compiler uses the following steps (in order) to match single argument signatures with single argument function calls.

  1. Exact ...

Get Navigating C++ and Object-Oriented Design 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.