title: Assigning C++ function pointers to member functions of the same object
body: <p>How do I get the function pointer assignments (and maybe the rest) in test.calculate to work?</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  class test {
  
      int a;
      int b;
  
      int add (){
          return a + b;
      }
  
      int multiply (){
          return a*b;
      }
  
      public:
      int calculate (char operatr, int operand1, int operand2){
          int (*opPtr)() = NULL;
  
          a = operand1;
          b = operand2;
  
          if (operatr == '+')
              opPtr = this.*add;
          if (operatr == '*')
              opPtr = this.*multiply;
  
          return opPtr();
      }
  };
  
  int main(){
      test t;
      std::cout &lt;&lt; t.calculate ('+', 2, 3);
  }
  </code></pre>