title: Why can't a class method call a global function with the same name?
body: <p>The following code shows a function call another function.<br>
  Both have the same name, but different signatures.<br>
  This works as expected.  </p>
  
  <pre><code>//declarations
  void foo();
  void foo(int);
  
  int main(){
    foo();
  }
  
  //definitions
  void foo(){
      foo(1);
  }
  void foo(int){}
  </code></pre>
  
  <p>The only difference I will make now, is wrap one of the functions into a structure:  </p>
  
  <pre><code>//declarations
  struct Bar{
      void foo();
  };
  void foo(int);
  
  int main(){
    Bar bar;
    bar.foo();
  }
  
  //definitions
  void Bar::foo(){
      foo(1);
  }
  void foo(int){}
  </code></pre>
  
  <p>This fails to compile.  </p>
  
  <pre><code>In member function ‘void Bar::foo()’:
  error: no matching function for call to ‘Bar::foo(int)’
           foo(1);
                ^
  note: candidate: void Bar::foo()
       void Bar::foo(){
            ^
  note:   candidate expects 0 arguments, 1 provided
  </code></pre>
  
  <p>I don't understand why it wants to call foo(int) as a method, when the global function exists.<br>
  It doesn't mention anything about ambiguity, it just can't find the function.  </p>
  
  <p>Why is this happening, and how can I fix it?  </p>
  
  <p><strong>side note:</strong>  I'm wrapping old C code in a C++ wrapper, and most of the C++ methods are calls to the global C functions which pass in the wrapped struct implicitly.  It's a similar situation to what is happening above (in terms of compiler errors).</p>