I'm trying to create a hash table using chaining and I need to use a dynamic array because if the load of the table gets to a certain point, I need to rehash using a larger table size. I'm using MSVC++ 6.0 and it's throwing some errors that I'll include later. First off, here is my linked list (the chaining part) struct:
struct Node *Next;
My dynamic array:
struct Node *HashTable;
HashTable = new Node[HASH_TABLE_SIZE];
Now I'm trying to use that as the hash table and to make it larger I do:
HashTable = new Node[NEW_HASH_TABLE_SIZE];
This is the error MSVC++ 6.0 is giving me:
htchain.cpp(139) : error C2501: 'HashTable' : missing storage-class or type specifiers
htchain.cpp(139) : error C2040: 'HashTable' : 'int' differs in levels of indirection from 'struct Node *'
htchain.cpp(139) : error C2440: 'initializing' : cannot convert from 'struct Node *' to 'int'
This conversion requires a reinterpret_cast, a C-style cast or function-style cast
I can't even initialize the table, let alone ever expand it. I tried making a basic dynamic array like this:
int *vector = new int;
And that works, but if I try this, it throws the same error:
vector = new int;
The odd thing is that if I do:
int *vector = new int; //or this:
struct Node *HashTable[HASH_TABLE_SIZE];
There are no errors (but then I can never expand the table size, and that's my problem in the first place!). I'd really appreciate any help, this is really important.