C++primer 6.6节练习

练习6.49

函数匹配的第一步是选定本次调用对应的重载函数集,集合中的函数称为候选函数;

第二步考察本词条用提供的实参,然后从候选函数中选出能被这组实参调用的函数,这些选出的函数被称为可行函数。

练习6.50

a)不合法,具有二义性;

b)f(int)

c) f(int, int)

d)f(double,double)

练习6.51

 

 1 void f ()
 2 {
 3     cout << 1 << endl;
 4 }
 5 void f (int i)
 6 {
 7     cout << 2 << endl;
 8 }
 9 void f (int i, int j)
10 {
11     cout << 3 << endl;
12 }
13 void f(double i, double j = 3.14)
14 {
15     cout << 4 << endl;
16 }
17 int main()
18 {
19     //f(2.56, 42);
20     f(42);
21     f(42, 0);
22     f(2.56, 3.14);
23     system("pause");
24     return 0;
25 }

 

posted @ 2017-08-04 13:51  五月份小姐  阅读(191)  评论(0编辑  收藏  举报