Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
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
Old Apr 28th, 2008, 12:41 PM   #2
Jabo
Not a user?
 
Join Date: Sep 2007
Posts: 245
Rep Power: 1 Jabo is on a distinguished road
Re: initilizer incmplete type

c++ Syntax (Toggle Plain Text)
  1. int Size() const {return _size;}

This doesn't look right to me, you have the const keyword without a name.
Jabo is offline   Reply With Quote
Old Apr 28th, 2008, 4:19 PM   #3
Jessehk
The Oblivious One
 
Jessehk's Avatar
 
Join Date: May 2005
Location: Ontario, Canada
Posts: 630
Rep Power: 4 Jessehk is on a distinguished road
Re: initilizer incmplete type

Quote:
Originally Posted by Jabo View Post
c++ Syntax (Toggle Plain Text)
  1. int Size() const {return _size;}

This doesn't look right to me, you have the const keyword without a name.
Jabo, the const there indicates that when the method is called, it does not modify the object.
__________________
Dr. Zoidberg: [ecstatic] I'm going to a movie... with FRIENDS!
Jessehk is offline   Reply With Quote
Old Apr 28th, 2008, 5:50 PM   #4
mbd
Programmer
 
Join Date: Nov 2007
Posts: 86
Rep Power: 1 mbd is on a distinguished road
Re: initilizer incmplete type

zip up the source and attach it
mbd is offline   Reply With Quote
Old Apr 28th, 2008, 8:23 PM   #5
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
Re: initilizer incmplete type

Thanks for the reply: here are the files
rs link:
PARSER.ZIP
__________________
-------------------------------------------------------------------------
I thought what I'd Do was, I'd pretend to be one of those deaf mutes
------------------------------------------------------------------------
JD-Salinger is offline   Reply With Quote
Old Apr 29th, 2008, 2:58 AM   #6
Cache
Hobbyist
 
Join Date: Sep 2005
Posts: 259
Rep Power: 3 Cache is on a distinguished road
Re: initilizer incmplete type

You need to:
#include "Scanner.h"
#include "SymTab.h"
#include "FunTab.h"
#include "Store.h"
in either Parser.h or main.cpp

#include <cassert> in PTree.h

And there's an error in SymTab.cpp at line 54 about calling strcmp with 3 arguments. No doubt you meant to usestrncmp.
Cache is offline   Reply With Quote
Old Apr 29th, 2008, 5:28 AM   #7
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
Re: initilizer incmplete type

Quote:
Originally Posted by Cache View Post
You need to:
#include "Scanner.h"
#include "SymTab.h"
#include "FunTab.h"
#include "Store.h"
in either Parser.h or main.cpp

#include <cassert> in PTree.h

And there's an error in SymTab.cpp at line 54 about calling strcmp with 3 arguments. No doubt you meant to usestrncmp.
THanks a lot cache!!!! I am so STUPID!!!!!!!!!!!!!!!!!!! whoooo!!!! i just need to include those files.... and i checked the scanner.h header file... there's still some error in the ACCEPT method ill give it another check... thanks again... a big help
__________________
-------------------------------------------------------------------------
I thought what I'd Do was, I'd pretend to be one of those deaf mutes
------------------------------------------------------------------------
JD-Salinger is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Arrays with Generic Type azurik Java 6 Jun 14th, 2006 12:31 PM
Pointer return type,.. ??? Mack1982 C++ 28 May 26th, 2006 8:02 PM
base type has incomplete type Eric the Red C++ 4 Mar 3rd, 2006 8:04 PM
Conversion problem. string type to type int. HackeZ C++ 4 Dec 14th, 2005 6:52 PM
Defining a bool type nnxion C 6 Oct 7th, 2005 8:39 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:14 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC