View Single Post
Old Apr 28th, 2008, 6:36 AM   #1
JD-Salinger
Unknown
 
JD-Salinger's Avatar
 
Join Date: Apr 2008
Location: unknown
Posts: 57
Rep Power: 1 JD-Salinger is on a distinguished road
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

c++ Syntax (Toggle Plain Text)
  1. #include "Parser.h"
  2.  
  3. const int maxBuf=100;
  4. const int maxSymbols=40;
  5.  
  6.  
  7. int main()
  8. {
  9.  
  10.  
  11. char buf[maxBuf];
  12. Status status;
  13. SymbolTable symTab(maxSymbols);
  14. FunctionTable funTab(symTab,funArr);
  15. Store store(maxSymbols,symTab);
  16.  
  17. do
  18. {
  19. cout<<">"; //prompt
  20. cin.getline(buf,maxBuf);
  21. Scanner scanner(buf);
  22. Parser parser(scanner,store,funTab,symTab);
  23. status=parser.Eval();
  24. }while(status!=stQuit);
  25.  
  26. return 0;
  27.  
  28. }

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
c++ Syntax (Toggle Plain Text)
  1. #include <cmath>
  2. class SymbolTable; //forward declaration
  3.  
  4. typedef double (*PtrFun) (double);
  5. const int maxIdFun = 16;
  6.  
  7. class FunctionEntry
  8. {
  9. public:
  10. PtrFun pFun;
  11. char* strFun;
  12. };
  13.  
  14.  
  15. extern FunctionEntry funArr[];
  16.  
  17. class FunctionTable
  18. {
  19. public:
  20. FunctionTable(SymbolTable& symTab,FunctionEntry funArr[]);
  21. int Size() const {return _size;}
  22. PtrFun GetFun (int id) {return _pFun[id];}
  23. private:
  24. PtrFun _pFun[maxIdFun];
  25. int _size;
  26. };

FunTab.cpp

c++ Syntax (Toggle Plain Text)
  1. #include "SymTab.h"
  2. #include "FunTab.h"
  3.  
  4. #include <cmath>
  5. #include <cstring>
  6. #include <cassert>
  7. using namespace std;
  8.  
  9. double CoTan(double x)
  10. {
  11. double y=tan(x);
  12. if(y==0)
  13. {
  14. cout<<"cotan of "<<x<<" undefined\n";
  15. return HUGE_VAL;
  16. }
  17. return 1.0/y;
  18. };
  19.  
  20.  
  21. FunctionEntry funArr [maxIdFun] =
  22. {
  23. log, "log",
  24. log10,"log10",
  25. exp, "exp",
  26. sqrt, "sqrt",
  27. sin, "sin",
  28. cos, "cos",
  29. tan, "tan",
  30. CoTan,"cotan",
  31. sinh, "sinh",
  32. cosh, "cosh",
  33. tanh, "tanh",
  34. asin, "asin",
  35. acos, "acos",
  36. atan, "atan",
  37. 0, ""
  38. };
  39.  
  40.  
  41. FunctionTable::FunctionTable(SymbolTable& symTab,FunctionEntry funArr[])
  42. :_size(0)
  43. {
  44. for(int i=0; i<maxIdFun; ++i)
  45. {
  46. int len=strlen(funArr[i].strFun);
  47. if(len==0)
  48. break;
  49. _pFun[i]=funArr[i].pFun;
  50. cout<< funArr[i].strFun<<endl;
  51. int j=symTab.ForceAdd(funArr[i].strFun,len);
  52. assert(i==j);
  53. ++_size;
  54. }
  55. }

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
------------------------------------------------------------------------
JD-Salinger is offline   Reply With Quote