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 ...
Get C++ Templates: The Complete Guide 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.