I have this problem when I am trying to build my project, I have 6 errors of Undefined symbols with my functions:
Showing Recent Issues Undefined symbol: Hashint::deleteHash(int)
Undefined symbol: Hashint::insertHash(int)
Undefined symbol: Hashint::searchHash(int)
Undefined symbol: Hashint::print()
Undefined symbol: HashTable<int, int>::HashTable(int)
Undefined symbol: vtable for Hashint
I have a template class with an inner class (Item):
template <class T, class K>
class HashTable
{
public:
enum state {empty, full, deleted};
class Item
{
public:
T data;
K key;
state flag;
Item(){}
Item(T d, K k, state f){ data=d; key=k; flag=f;}
};
public:
Item* table;
int size;
HashTable(int sizeHash);
virtual ~HashTable() {}
virtual int h1(K k);
virtual int h2(K k);
//returns the index of the hashing table for the key k at the try number i
virtual int hash(K k, int i);
virtual int searchHash(K k); // searches and return the index
virtual int insertHash(K k); // insert
virtual void deleteHash(K k); // delete
virtual void print();
};
and I have my class Hashint that inherit from hashtable:
class Hashint : public HashTable<int,int> {
public:
int sizeTable;
Item* table;
Hashint(int size):HashTable<int, int>(size)
{
table= new Item [size];
sizeTable = size;
for (int i=0; i<sizeTable; i++)
table[i].flag = empty;
}
int h1(int k);
int h2(int k);
int hash(int k, int i);
int searchHash(int k);
int insertHash(int k);
void deleteHash(int k);
void print();
};
I have also a cpp file of my Hashtable class but the post will be too long if I post it...
I don't understand what's the problem, I did the inheritance wrong? Or maybe the problem is the template? I would be really happy if you could help me! Thank u!!