I am trying to build a Hash table and with what I have learned using online tutorials I have come up with the following code
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;
const int SIZE = 100;
int hash(string);
class Node
{
   public:
      Node();
      Node(string);
      int hash(int value);
   private:
      string data;
      Node* next;
   friend class HashTable;
};
Node::Node() {
  data = "";
  next = NULL;
}
Node::Node(string) {
  data = "";
  next = NULL;
}
int Node::hash(int value) {
   int y;
   y = value % SIZE;
}
class HashTable {
public:
    HashTable();
      HashTable(int);
      ~HashTable();
      void insertItem(string);
      bool retrieveItem(string);
private:
      Node* ht;
};
HashTable::HashTable() {
  ht = new Node[SIZE];
}
HashTable::HashTable(int max) {
  ht = new Node[max];
}
HashTable::~HashTable() {
   delete[] ht;
}
void HashTable::insertItem(string name) {
    int val = hash(name);
    for (int i = 0; i < name.length(); i++)
        val += name[i];
}
bool HashTable::retrieveItem(string name) {
    int val = hash(name);
    if (val == 0 ) {
        cout << val << " Not Found " << endl;
    }
    else {
        cout << val << "\t" << ht->data << endl;
    }
}
void print () {
    //Print Hash Table with all Values
}
int main() {
   HashTable ht;
   ht.insertItem("Allen");
   ht.insertItem("Tom");
   ht.retrieveItem("Allen");
   //data.hash(int val);
   //cout << ht;
   system("pause");
   return 0;
}
int hash(string val) {
    int key;
    key = val % SIZE;
}
I am trying to insert string values and validate if the name exists using the retrieveItem function. Also, how do I go about printing the HashTable with values.
Any help will be highly appreciated.
Vish
 
     
    