CXX0030: Error: expression cannot be evaluated

I'm currently implementing my own version of a hash table in C++ using VS2010. I'm having trouble with some of the variables showing in the watch window. Those for the key and value, inisde the hash entry of a table.

The code is shown below:

#include <string>

template <class T>
class HashEntry
{
private:
int key; //lookup key
T value; //hash data

public:
HashEntry(int key, T value);
int getKey();
T getValue();
void setValue(T value);
};

template <class T>
HashEntry<T>::HashEntry(int key, T value)
{
this->key = key;
this->value = value;
};

template <class T>
int HashEntry<T>::getKey()
{
return key;
};

template <class T>
T HashEntry<T>::getValue()
{
return value;
};

template <class T>
void HashEntry<T>::setValue(T value)
{
this->value = value;
};


template <class T>
class DeletedEntry:public HashEntry<T>
{
private:
static DeletedEntry *entry;
DeletedEntry(): HashEntry(-1, "Deleted"){
} //function that adds special deleted entry

public:
static DeletedEntry *getUniqueDeletedEntry();
};

template <class T>
DeletedEntry<T> *DeletedEntry<T>::getUniqueDeletedEntry()
{
if (entry == NULL)
{
entry = new DeletedEntry();
}
return entry;
};

template <class T>
DeletedEntry<T> *DeletedEntry<T>::entry = NULL;

const int TABLE_SIZE = 128;

template <class T>
class HashTable
{
private:
HashEntry<T> **table;

public:



HashTable();
void insert(int key, T value);
void remove(int key);
T find(int key);
~HashTable();
};

template <class T>
HashTable<T>::HashTable()
{
table = new HashEntry<T>*[TABLE_SIZE];
for(int i = 0; i < TABLE_SIZE; i++)
{
table[i] = NULL;
}
};

//Insert method
template <class T>
void HashTable<T>::insert(int key, T value)
{
int hashFunc = (key % TABLE_SIZE);
int inithashFunc = -1;
int indexOfDeletedEntry = -1;

while (hashFunc != inithashFunc && (table[hashFunc] == DeletedEntry<T>::getUniqueDeletedEntry() || table[hashFunc] != NULL && table[hashFunc]->getKey() != key))
{
if (inithashFunc == -1)
{
inithashFunc = hashFunc;
}
if (table[hashFunc] == DeletedEntry<T>::getUniqueDeletedEntry())
{
indexOfDeletedEntry = hashFunc;
}
hashFunc = (hashFunc + 1) % TABLE_SIZE;
}
if ((table[hashFunc] == NULL || hashFunc == inithashFunc) && indexOfDeletedEntry != -1)
{
table[indexOfDeletedEntry] = new HashEntry<T>(key, value);
}
else if (inithashFunc != hashFunc)
{
if (table[hashFunc] != DeletedEntry<T>::getUniqueDeletedEntry() && table[hashFunc] != NULL && table[hashFunc]->getKey() == key)
{
table[hashFunc]->setValue(value);
}
else
{
table[hashFunc] = new HashEntry<T>(key, value);
}
}

};

//Remove method
template <class T>
void HashTable<T>::remove(int key)
{
int hashFunc = (key % TABLE_SIZE);
int initHashFunc = -1;

while (hashFunc != initHashFunc && (table[hashFunc] == DeletedEntry<T>::getUniqueDeletedEntry() || table[hashFunc] != NULL && table[hashFunc]->getKey() != key))
{
if (initHashFunc == -1)
{
initHashFunc = hashFunc;
}
hashFunc = (hashFunc + 1) % TABLE_SIZE;
}
if (hashFunc != initHashFunc && table[hashFunc] != NULL)
{
delete table[hashFunc];
table[hashFunc] = DeletedEntry<T>::getUniqueDeletedEntry();
}
};

//Find method
template <class T>
T HashTable<T>::find(int key)
{
int hashFunc = (key % TABLE_SIZE);
int initHashFunc = -1;

while (hashFunc != initHashFunc && (table[hashFunc] == DeletedEntry<T>::getUniqueDeletedEntry() || table[hashFunc] != NULL && table[hashFunc]->getKey() != key))
{
if (initHashFunc == -1)
{
initHashFunc = hashFunc;
}
hashFunc = (hashFunc + 1) % TABLE_SIZE;
}
if (table[hashFunc] == NULL || hashFunc == initHashFunc)
{
return -1;
}
else
{
return table[hashFunc]->getValue();
}
};

//Destructor
template <class T>
HashTable<T>::~HashTable()
{
for (int i = 0; i < TABLE_SIZE; i++)
{
if (table[i] != NULL && table[i] != DeletedEntry<T>::getUniqueDeletedEntry())
{
delete table[i];
}
}
delete[] table;
};
Topic archived. No new replies allowed.