Appendix B. Overload Resolution
Overload resolution is the process that selects the function to call for a given call expression. Consider the following simple example:
void display_num(int); // (1) void display_num(double); // (2) int main() { display_num(399); // matches (1) better than (2) display_num(3.99); // matches (2) better than (1) }
In this example, the function name display_num() is said to be overloaded. When this name is used in a call, a C++ compiler must therefore distinguish between the various candidates using additional information; mostly, this information is the types of the call arguments. In our example it makes intuitive sense to call the int version when the function is called with an integer argument ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access