c++ - 1 IntelliSense: a value of type "StatementTable::StatementFunc" cannot be assigned to an entity of type "StatementTable::StatementState" -


statementstatefunction [ ] array of functions return statementstate , statearray [getinputtoken(t)] [currentstate] state table tells statementstatefunction [ ] function call, yet compiler says cannot assign statementfunc statementstate though methods called in statementstatefunction[] return statementstate

in statementtable.cpp

void statementtable::buildstatement (token & t) {   statementstate currentstate (startstatement);     {     currentstate = statementstatefunction [ statearray[getinputtoken(t)][currentstate] ];   }    while (currentstate != statementcomplete); } 

in statementtable.h

typedef statementstate          (*statementfunc)    (token &);  static  token::uchar        statearray [numtokeinputs] [numberstates];  static  statementfunc       statementstatefunction  []; 

let's analyze expression:

currentstate = statementstatefunction [ statearray[getinputtoken(t)][currentstate] ]; 

you have 3 array indizes here, getinputtoken(t), currentstate, statearray[x][y]. array indizes have integral numbers (int, short, char, long etc.).

  • getinputtoken seems function. source cannot tell whether returns integral type or not.
  • currentstate of type statementstate. it's not clear type is, if not of integral type nor has implicit conversion such type, cannot used array index.
  • statearray[x][y] of type token::uchar. thyt should ok, uchar looks typedef integral type.

what remains of expression assignment. has form currentstate = statementstatefunction[x]. statementstatefunction[x] statementfunc, i.e. function pointer. currentstate of type statementstate. you cannot assign function pointer statementstate, @ least error message says.

i assume want call function, token given argument buildstatement. code, made bit more readable, this:

void statementtable::buildstatement (token & t) {   statementstate currentstate = startstatement;     {     auto tokenindex = getinputtoken(t);     auto funcindex = statearray[tokenindex][currentstate];      auto function = statementstatefunction[funcindex];     //this missing: function call     currentstate = function(t);   }    while (currentstate != statementcomplete); }  

Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -