title: Expression Must have (pointer-to) function type error
body: <p>I decided it was about time I finished the little infix calculator I started a week ago, and ran into a problem in my evaluate function. My switch statement seems to have an issue with the way I'm handling my array over operator structures. I'm not entirely sure what I'm doing wrong. This isn't the only error I'm getting, but I'm sure that if I fix this then the other issues should be easier to clear up. Obviously my code ins incomplete, but considering what I have so far am I on the right track?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;sstream&gt;
  
  using namespace std;
  
  bool die(const string &amp;msg);
  
  //stack class
  class Stack{
  public:
      Stack();
      void push(const double &amp;val);
      void push(const string &amp;oper);
      double popnum();
      string popop();
      double getopele();
      double getnumele();
      unsigned getarity(string token);
      unsigned getprec(string token);
      string topop();
  private:
      static const unsigned MAX=30;
      string opstack[MAX];
      double numstack[MAX];
      unsigned opele;
      unsigned numele;
  };
  //operators
  bool add(double &amp;r, double &amp;x, double &amp;y);
  bool subtract(double &amp;r, double &amp;x, double &amp;y);
  bool multiply(double &amp;r, double &amp;x, double &amp;y);
  bool divide(double &amp;r, double &amp;x, double &amp;y);
  
  //operator type
  struct OP{
      string name;
      void * func;
      unsigned arity;
      unsigned prec;
      bool lass;
      string descrip;
  };
  //operator table
  OP op[]={{"+", add, 2, 4, true, "2+3 is 5"},
          {"-", subtract, 2, 4, true, "2-3 is -1"},
          {"*", multiply, 2, 6, true, "2*3 is 6"},
          {"/", divide, 2, 6, true, "2/3 is 0.666666..., div by 0 illegal"}};
  unsigned OPELE =sizeof(op)/sizeof(op[0]);
  
  
  //Manip
  unsigned findindex(string token);
  bool parseval(double &amp;t, const string &amp;token);
  double parseforeval(double &amp;result, string line);
  void evaluate(double &amp;result, Stack &amp;s);
  bool weird(double x);
  
  int main(){
      for(string line; getline(cin, line);){
          if(line=="QUIT") break;
          if(line.empty()) continue;
          if(line=="DOC")
              for(unsigned i=0; i&lt;OPELE; i++)
                  cout&lt;&lt;op[i].name&lt;&lt;" | "&lt;&lt;op[i].descrip&lt;&lt;'\n';
          double result;
          if(parseforeval(result, line)){
              cout&lt;&lt;result&lt;&lt;'\n';
          }else{
              cout&lt;&lt;"Could not understand input\n\n";
          }
      }
  }
  
  Stack::Stack(){
      opele=0;
      numele=0;
  }
  
  void Stack::push(const double &amp;val){
      if(MAX) die("Stack Overflow");
      numstack[numele++]=val;
  }
  
  void Stack::push(const string &amp;oper){
      if(MAX) die("Stack Overflow");
      opstack[opele++]=oper;
  }
  
  double Stack::popnum(){
      if(!numele) die("Stack Underflow");
      return numstack[--numele];
  }
  
  string Stack::popop(){
      if(!opele) die("Stack Underflow");
      return opstack[--opele];
  }
  
  double Stack::getopele(){
      return opele;
  }
  
  double Stack::getnumele(){
      return numele;
  }
  
  unsigned Stack::getprec(string token){
      unsigned i=findindex(token);
      return op[i].prec;
  }
  
  unsigned Stack::getarity(string token){
      unsigned i=findindex(token);
      return op[i].arity;
  }
  
  string Stack::topop(){
      if(!opele) die("Undeflow");
      return opstack[opele-1];
  }
  
  double parsforeval(double &amp;result, string line){
      istringstream sin(line);
      Stack s;
      for(string token; sin&gt;&gt;token;){
          double t;
          if(parseval(t, token)){
              s.push(t);
          }else if(token=="("){
              s.push(parsforeval(result, line));
          }else if(s.getprec(s.topop()) &gt;s.getprec(token)){
              //write eval function
              s.push(token);
          }else if(token== ")"){
              if(!s.getnumele()) die("Bad format");
              return s.popnum();
          }else{
              s.push(token);
          }
      }
      while(s.getopele()){
          evaluate(result, s);
      }
  }
  
  void evaluate(double &amp;result, Stack &amp;s){
      unsigned i= findindex(s.popop());
      switch(op[i].arity){
          case 1:
              if(s.getnumele()&lt;1) die("Underflow");
              double x = s.popnum();
              if(  !reinterpret_cast&lt;bool (*)(double &amp;, double &amp;)&gt; !op[i].func (result, x)  ) die("No OP");
              break;
          case 2:
              if(s.getnumele()&lt;2) die("Underflow");
              double y = s.popnum();
              double x = s.popnum();
              if(  !reinterpret_cast&lt;bool (*)(double &amp;, double &amp;,double &amp;)&gt; op[i].func (result, x, y)  ) die("No OP");
              break;
          case 3:
              if(s.getnumele()&lt;3) die("Underflow");
              double z = s.popnum();
              double y = s.popnum();
              double x = s.popnum();
              if(   !reinterpret_cast&lt;bool (*)(double &amp;, double &amp; , double &amp; , double &amp;)&gt;op[i].func (result, x, y, z)   ) die("No OP");
              break;
          default:
              die("uuuuuuhhhh i have no idea");
              break;
      }
      s.push(result);
  }
  
  bool add(double &amp;r, double &amp;x, double &amp;y){
      double t = x + y;
      if( weird(t) )  return false;
      r = t;
      return true;
  }
  
  bool subtract(double &amp;r, double &amp;x, double &amp;y){
      double t = x - y;
      if( weird(t) )  return false;
      r = t;
      return true;
  }
  
  bool multiply( double &amp; r, double&amp; x, double &amp;y ){
      double t = x * y;
      if( weird(t) )  return false;
      r = t;
      return true;
  }
  
  bool divide( double &amp; result, double &amp;x, double &amp;y ){
      double t = x / y;
      if( weird(t) )  return false;
      result = t;
      return true;
  }
  
  unsigned findindex(string token){
      for(unsigned i=0; i&lt;OPELE; i++)
          if(op[i].name==token)
              return i;
      return UINT_MAX;
  
  }
  
  bool parseval(double &amp;val, const string &amp;token){
      istringstream sin( token );
      double t;
      if( !(sin &gt;&gt;t) )  return false;
      char junk;
      if( sin &gt;&gt;junk )  return false;
      val = t;
      return true;
  }
  
  bool weird( double x ){
      return  x != x || x != 0 &amp;&amp; x == 2*x;
  }
  
  bool die(const string &amp;msg){
      cout&lt;&lt;"Error: "&lt;&lt;msg;
      exit(EXIT_FAILURE);
  }
  </code></pre>