Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          function-overloading/overloading-8.cc - A single best match again - slightly surprising perhaps.Lecture 3 - slide 9 : 27
Program 9

/* One single best match: user-defined conversion. One match at a lower level. */
/* Two not matching at all.                                                    */

#include <iostream>
#include <string>
#include "point.h"

using namespace std;

void f(char *c){                      // No match
  cout << "f(char *)" << endl;
}

void f(float c){                      // Best match - by promotion
  cout << "f(float)" << endl;
}

void f(string c){                     // No match
  cout << "f(string)" << endl;
}

void f(...){                          // Match at lower level - ellipsis
  cout << "f(...)" << endl;
}

int main(){
  Point p(5.5);   
  f(p);           // A single best match: f(float)
                  // the conversion operator point -> double,
                  // after a double to float conversion  

                  // f(char *) and f(string) do not match at all.
                  // f(...) matches, but it is in a lower matching category
}