Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          function-overloading/overloading-3.cc - 'Float to double' conversion prefered over 'float to int' and 'float to long int'.Lecture 3 - slide 9 : 27
Program 4

/* One best match using promotion. Two others at a lower level 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;
}

void f(double d){                      // Match:  promotion
  cout << "f(double)" << endl;
}

int main(){
  float c = 5.5;
  f(c);             // A single best match:  f(double)  
                    // The float to double promotion is in another category than
                    // float -> int  and  float -> long int.
}