title: How to call member function through member function pointer?
body: <p>I want to call member-functions through member-function-pointers. The calling function is also a member.</p>
  
  <pre><code>class A;
  
  typedef int (A::*memFun)();
  
  class A
  {
      int P(){return 1;}
      int Q(){return 2;}
      int R(){return 3;}
  
      int Z(memFun f1, memFun f2)
      {
          return f1() + f2(); //HERE
      }
  public: 
      int run();
  };
  
  int A::run()
  {
      return Z(P, Q);
  }
  
  int main()
  {
      A a;
      cout &lt;&lt; a.run() &lt;&lt; endl;
  }
  </code></pre>
  
  <p>I am not doing it correctly, and am getting error-</p>
  
  <pre><code>main.cpp:15:19: error: must use '.*' or '-&gt;*' to call pointer-to-member function in 'f1 (...)', e.g. '(... -&gt;* f1) (...)'
           return f1() + f2(); //HERE
  </code></pre>
  
  <p>Please show the correct way to do it.</p>
  
  <p><strong>EDIT</strong> - there is another error, which is solved by having-</p>
  
  <pre><code>return Z(&amp;A::P, &amp;A::Q);
  </code></pre>