title: Why does setting function pointer as pointer and pointerpointer work?
body: <p>One more time I got trapped by pointer logic.
  The following code uses a function typedef tOutFunction.
  It defines a global variable to this function pointer and a set method.</p>
  
  <p>Why does</p>
  
  <pre><code>SetOutFunction(OutFunction);
  </code></pre>
  
  <p>and</p>
  
  <pre><code>SetOutFunction(&amp;OutFunction);
  </code></pre>
  
  <p>both work? How could autoconversion work in this place. Or is one of it wrong and it works by accident?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  typedef int (*tOutFunction)(const char*);
  
  int OutFunction(const char* out)
  {
    std::cout &lt;&lt; "OutFunction:" &lt;&lt; out &lt;&lt; "\n";
    return 10;
  }
  
  tOutFunction out__ = 0;
  
  void SetOutFunction(tOutFunction outFunc)
  {
    out__ = outFunc;
  }
  
  int main()
  {
    SetOutFunction(OutFunction);
    std::cout &lt;&lt; out__("Without Ref") &lt;&lt; "\n";
  
    SetOutFunction(&amp;OutFunction);
    std::cout &lt;&lt; out__("With Ref") &lt;&lt; "\n";
  
    return 0;
  }
  </code></pre>
  
  <p>Also tried it here:
  <a href="http://codepad.org/yfxj2QAo" rel="nofollow">http://codepad.org/yfxj2QAo</a></p>