Case
void f (); void f (int); void f (intint); void F (doubledouble3.14);
Matching principle:
1) The number of formal parameters is equal to the number of arguments provided by this call
2) The type of each argument is the same as the corresponding parameter type, or the type of the forming parameter can be converted;
Find the best match:
1) The matching of each argument of the function is not inferior to that of other feasible function;
2) The match of at least one argument is better than that provided by other feasible functions;
Example:
A) F (2.56),b) F(d), C) F (0);d) F ( 3.9,9.8);
A) The feasible function is void f (int, int) with void f (double, double =3.2). However, the best match does not exist, considering that the first parameter void F (double, double =3.2) has a distinct advantage;
But considering the second argument 38 o'clock, void f (int, int) has obvious advantages and is ambiguous and rejects its request;
b) void f (int);
c) void f (int, int);
D) Double f (double, double = 3.2);
tips: When you overload a function, you should try to avoid forcing type conversions.
function matching and const arguments
Record (acount&); Record (const acount&); Const // call record (const acount&); Record (b); // call Record (acount&);
function overloading of C + + (function matching)