469,127 Members | 1,413 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,127 developers. It's quick & easy.

No Type Specified Error

Ganon11
3,652 Expert 2GB
When I try and compile my code, I'm getting the error:
Expand|Select|Wrap|Line Numbers
  1. In file included from HTTest.cpp:2:
  2. HashTable.h:52: error: ISO C++ forbids declaration of `vector' with no type
Line 52 from my program is:

Expand|Select|Wrap|Line Numbers
  1.         vector<list<int> > theLists;
As you can see, it clearly has a type. So does list.

I think the problem lies in the fact that it can't find the vector or list header files (or maybe just the list header file). Here's my trimmed up code:

Expand|Select|Wrap|Line Numbers
  1. #ifndef HASH_TABLE
  2. #define HASH_TABLE
  3.  
  4. #include <vector>
  5. #include <list>
  6. #include <algorithm>
  7.  
  8. class HashTable {
  9.     public:
  10.         explicit HashTable(int size = 101);
  11.  
  12.         bool contains(int x) const;
  13.  
  14.         void makeEmpty();
  15.  
  16.         bool insert(int x);
  17.  
  18.         bool remove(int x);
  19.  
  20.         int avgLoad();
  21.  
  22.     private:
  23.         vector<list<int> > theLists; // This is line 52 in my 'real code'.
  24.         int currentSize;
  25.  
  26.         int myhash(int x) const;
  27. };
  28.  
  29.  
  30. #endif
  31.  
Any ideas?

Thanks a lot guys!
Oct 15 '07 #1
2 1317
oler1s
671 Expert 512MB
Everything is in namespace std. So it's std::vector and std::list, and so on.

Resist the temptation to drop a using namespace std; right after your includes. The using directive easily pollutes, but doing so in header files is downright disastrous.
Oct 15 '07 #2
Ganon11
3,652 Expert 2GB
I can't believe I forgot that! Thanks a lot, it fixed it.
Oct 15 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

21 posts views Thread by Batista, Facundo | last post: by
4 posts views Thread by j | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.