title: C++ overloaded function calling version of itself with more arguments
body: <p>I am using function overload to have a general version of a behaviour and a more usual one. The usual function just picks a default value for the second argument that actually depends on the first, and the compiler is giving me an error because it does not even recognize the existence of the second function. I also tried to do it with default values, but because the default depends on the first argument, the compiler does not seem to accept it.</p>
  
  <p>So, here are simplified examples just for illustration.
  Function overloading case:</p>
  
  <pre><code>#include &lt;stdio.h&gt;  
  struct pair {
    int x;
    int y;
  };
  
  int func(pair a){
    return func(a, a.y);
  }
  
  int func(pair a, int b) {
    return a.x*b;
  }
  
  int main() {
    pair z;
    z.x = 2;
    z.y = 4;
    printf("%d\n", func(z));
    printf("%d\n", func(z,12));
  }
  </code></pre>
  
  <p>This gives me the error:</p>
  
  <pre><code>a.c: In function ‘int func(pair)’:
  a.c:9:21: error: too many arguments to function ‘int func(pair)’
  a.c:8:5: note: declared here"
  </code></pre>
  
  <p>Example with default values:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  struct pair {
    int x;
    int y;
  };
  
  
  int func(pair a, int b = a.y) {
    return a.x*b;
  }
  int main() {
       pair z;
       z.x = 2;
       z.y = 4;
       printf("%d\n", func(z));
       printf("%d\n", func(z,12));
  }
  </code></pre>
  
  <p>Gives me the following error: "local variable a may not appear in this context"</p>
  
  <p>So, is there any way in C++ to emulate this behaviour? I never had this problem in other languages, like Java or even in ASP.</p>
  
  <p>Thank you all.</p>