title: Exercise about pointer to function in C++
body: <p>I have an exercise like that. The requirement is to write code in the section</p>
  <pre><code>#include &lt;iostream&gt;
  
  int minus (int a, int b) {
      return a - b;
  }
  
  void calculate(int a, int b)
  {
      int (*myfunc)(int, int);
        
      // STUDENT ANSWER BEGIN
  
  
      // STUDENT ANSWER END
  
      int ans = (*myfunc)(a, b);
      printf(&quot;Output of calculation is %d.\n&quot;, ans);
  }
  int main() {
      calculate(1,2);
      return 0;
  }
  </code></pre>
  <p>When I write</p>
  <pre><code>        int (*myfunc) (int, int) = add;
          int temp = (*myfunc)(a, b);
          cout &lt;&lt; temp;
  </code></pre>
  <p>the value of <em>temp</em> = -1 as expected (just for test) but I can't get the value of <em>ans</em>. So, I figure that two *(<em>myfunc)</em> is different. How can I fix that?
  Thank you very much!</p>