Affect the position of c ++ function declarations for overloaded functions

c ++ for compatibility c, also used the (false) single-pass compiler. This particularly affects function overloading resolution (when the c ++ compiler reads a function call statement, it must select the best function from the function of the same name has been seen in, even if the code behind the emergence of a more appropriate match)

 

 1 #include<iostream>
 2 using namespace std;
 3 void f(int a )
 4 {
 5     cout << (int)a << endl;
 6 }
 7 void b(char a)
 8 {
 9     f(a);
10 }
11 void f(char a)
12 {
13     cout << a << endl;
14 }
15 void bb(char a)
16 {
17     f(a);
18 }
19 int main()
20 {
21     b('d');
22     bb('d');
23 }

 

vs2015 is output

100

d

Guess you like

Origin www.cnblogs.com/l2017/p/11368468.html