Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          function-overloading/overloading-4.cc - An ambiguity between 'float to int' and 'float to long int'.Lecture 3 - slide 9 : 27
Program 3

/* Mathces using standard conversions.  */

#include <iostream>
#include <string>

using namespace std;

void f(int i){                      // Match: standard conversion
  cout << "f(int)" << endl;
}

void f(long int i){                 // Match: standard conversion
  cout << "f(long int)" << endl;
}





int main(){
  float c = 5.5;
  f(c);             // error: call of overloaded  f(float&)  is ambiguous
                    // note: candidates are: void f(int)
                    // note:                 void f(long int)

}

// This example is continued in the next program...