|
Unknown
Join Date: Apr 2008
Location: unknown
Posts: 57
Rep Power: 1 
|
initilizer incmplete type
i am doing this program which is a parser calculator but when i compile it there's an error which is "FunctionTable funtab has initializer but incomplete type", i am using codeblocks 8.02, and my program is kinda long. I think my algorithms are correct and the only problem is in the syntax or how i coded it... here's a snipet of the main function
#include "Parser.h" const int maxBuf=100; const int maxSymbols=40; int main() { char buf[maxBuf]; Status status; SymbolTable symTab(maxSymbols); FunctionTable funTab(symTab,funArr); Store store(maxSymbols,symTab); do { cout<<">"; //prompt cin.getline(buf,maxBuf); Scanner scanner(buf); Parser parser(scanner,store,funTab,symTab); status=parser.Eval(); }while(status!=stQuit); return 0; }
its compiled as a one project, thats why it only had one header file, it is composed of 9 source files and 8 header files. i suppose that the problem is in the function table source file or function table header file...
FunTab.h
#include <cmath> class SymbolTable; //forward declaration typedef double (*PtrFun) (double); const int maxIdFun = 16; class FunctionEntry { public: PtrFun pFun; char* strFun; }; extern FunctionEntry funArr[]; class FunctionTable { public: FunctionTable(SymbolTable& symTab,FunctionEntry funArr[]); int Size() const {return _size;} PtrFun GetFun (int id) {return _pFun[id];} private: PtrFun _pFun[maxIdFun]; int _size; };
FunTab.cpp
#include "SymTab.h" #include "FunTab.h" #include <cmath> #include <cstring> #include <cassert> using namespace std; double CoTan(double x) { double y=tan(x); if(y==0) { cout<<"cotan of "<<x<<" undefined\n"; return HUGE_VAL; } return 1.0/y; }; FunctionEntry funArr [maxIdFun] = { log, "log", log10,"log10", exp, "exp", sqrt, "sqrt", sin, "sin", cos, "cos", tan, "tan", CoTan,"cotan", sinh, "sinh", cosh, "cosh", tanh, "tanh", asin, "asin", acos, "acos", atan, "atan", 0, "" }; FunctionTable::FunctionTable(SymbolTable& symTab,FunctionEntry funArr[]) :_size(0) { for(int i=0; i<maxIdFun; ++i) { int len=strlen(funArr[i].strFun); if(len==0) break; _pFun[i]=funArr[i].pFun; cout<< funArr[i].strFun<<endl; int j=symTab.ForceAdd(funArr[i].strFun,len); assert(i==j); ++_size; } }
should i provide a Link to the whole program? thank you very much...
__________________
-------------------------------------------------------------------------
I thought what I'd Do was, I'd pretend to be one of those deaf mutes
------------------------------------------------------------------------
|