class Node{
private:
std::string word;
int frequency;
public:
Node *next;
...
}
class Table{
private:
Node **row;
int size;
...
}
Table::Table(int s) {
size=s;
*row= new Node[size];
for(int i=0;i<size;i++) {
row[i] = new Node;
}
}
void Table::add(Node* n) {
int key= calc_key((*n).get_Word(),size);
if((row[key])!=0) {
Node* temp = row[key];
while(temp->next!=0) {
temp=temp->next;
}
temp->next=n;
delete temp;
}
else row[key]=n;
}
Size represents the amount of different linked lists I want to add to my hash_table (I'm using this system to avoid key-clashes).
There seems to be a problem in my add function, which seems to originate from the way I initiate my Table. When I want to add a Node to my Table (in my main function), the compiler never seems to notice my Table is still empty and the pointers are NULLpointers.