title: C++: Why member function has priority over global function
body: <p>Why in the next program the member function foo has priority over the global foo although the global one match the type?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  void foo(double val) { cout &lt;&lt; "double\n";}
  
  class obj {
  public:
    void callFoo() { foo(6.4); }
  private:
    void foo(int val) {cout &lt;&lt; "class member foo\n"; }
  };
  
  int main() { 
    obj o;
    o.callFoo();
  }
  </code></pre>