title: How to call function passed (function ptr passed as argument to function)
body: <p>In the command_rq line below, which does not compile, how do I call the function in this case?  How do I need to change the function to get this to work?</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  struct Command {
      bool RequestA() { cout &lt;&lt; "RequestA\n"; return true; }
      bool RequestB() { cout &lt;&lt; "RequestB\n"; return true; }
      bool RequestC() { cout &lt;&lt; "RequestC\n"; return true; }
  };
  
  typedef bool (Command::*Request)();
  
  class handler {
  public:
      handler(Command* cmd) : command_(cmd) { }
  
      // *** How to now call specific function passed?
      void doX(Request rq) { command_-&gt;rq(); }
      void doA() { doX(&amp;Command::RequestA); }
      void doB() { doX(&amp;Command::RequestA); }
      void doC() { doX(&amp;Command::RequestA); }
  private:
      Command* command_;
  };
  
  int main() {
      Command* pCmd = new Command;
      handler h(pCmd);
      h.doA();
  }
  </code></pre>