1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
#include <iostream>
using namespace std;
int mayor(int x, int y=2);
int mayor(int x, int y=2, int w=3);
int mayor(int x, int y=2, int w=3, int s=4);
int main()
{
cout << mayor(13, 4) << endl;
cout << mayor(15, 45, 23) << endl;
cout << mayor(10, 12, 56, 21) << endl;
return 0;
}
int mayor(int x, int y)
{
if(x>y) return x;
else return y;
}
int mayor(int x, int y, int w)
{
return mayor(mayor(x, y), w);
}
int mayor(int x, int y, int w, int s)
{
return mayor(mayor(x, y), mayor(w, s));
}
/*
Errores de compilacion
In function `int main()':
10: error: call of overloaded `mayor(int, int)' is ambiguous
4: note: candidates are: int mayor(int, int)
5: note: int mayor(int, int, int)
6: note: int mayor(int, int, int, int)
11: error: call of overloaded `mayor(int, int, int)' is ambiguous
5: note: candidates are: int mayor(int, int, int)
6: note: int mayor(int, int, int, int)
In function `int mayor(int, int, int)':
25: error: call of overloaded `mayor(int&, int&)' is ambiguous
18: note: candidates are: int mayor(int, int)
24: note: int mayor(int, int, int)
6: note: int mayor(int, int, int, int)
In function `int mayor(int, int, int, int)':
30: error: call of overloaded `mayor(int&, int&)' is ambiguous
18: note: candidates are: int mayor(int, int)
24: note: int mayor(int, int, int)
29: note: int mayor(int, int, int, int)
30: error: call of overloaded `mayor(int&, int&)' is ambiguous
18: note: candidates are: int mayor(int, int)
24: note: int mayor(int, int, int)
29: note: int mayor(int, int, int, int)
*/
|