title: How to get the address of an overloaded member function?
body: <p>I'm trying to get a pointer to a specific version of an <strong>overloaded</strong> member function. Here's the example:</p>
  
  <pre><code>class C
  {
    bool f(int) { ... }
    bool f(double) { ... }
  
    bool example()
    {
      // I want to get the "double" version.
      typedef bool (C::*MemberFunctionType)(double);
      MemberFunctionType pointer = &amp;C::f;   // &lt;- Visual C++ complains
    }
  };
  </code></pre>
  
  <p>The error message is "error C2440: 'initializing' : cannot convert from 'overloaded-function' to 'MemberFunctionType'"</p>
  
  <p>This works if <code>f</code> is not overloaded, but not in the example above. Any suggestion?</p>
  
  <h1>EDIT</h1>
  
  <p>Beware, the code above did not reflect my real-world problem, which was that I had forgotten a "const" - this is what the accepted answer points out. I'll leave the question as it is, though, because I think the problem could happen to others.</p>