previous | start | next

Overloaded Resolution (is tricky in C++)

Here is the same example, except that suppose the double version of getInput is changed to float:

Here are the declarations for the two versions of getInput

  1. void get(int&, int&, int&);
  2. void get(float&, float&, float&);

Which version should be called (1 or 2) for each of the following calls:

    int a, b, c;
    double x, y, z;
    float p, q, r;

    getInput(a,b,c);  // A. 
    getInput(x,y,z);  // B.
    getInput(p,q,r);  // C



previous | start | next