| function-overloading/overloading-7.cc - Now in an ambiguity situation. | Lecture 3 - slide 9 : 27 Program 8 |
/* Two standard conversions (at same level), one user-defined conversion at a lower level. */
/* One function not matching at all. */
#include <iostream>
#include <string>
#include "point.h"
using namespace std;
void f(Point p){ // Match at lower level
cout << "f(Point)" << endl;
}
void f(char *c){ // No match
cout << "f(char *)" << endl;
}
void f(char c){ // Match - standard conversion
cout << "f(char)" << endl;
}
void f(float c){ // Match - standard conversion
cout << "f(float)" << endl;
}
int main(){
double c = 5.5;
f(c); // error: call of overloaded f(double&) is ambiguous
// note: candidates are: void f(Point)
// note: void f(char)
// note: void f(float)
}