title: C++ Hash Chaining Function
body: <p>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</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;cstdlib&gt;
  
  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 &lt; name.length(); i++)
          val += name[i];
  }
  
  bool HashTable::retrieveItem(string name) {
      int val = hash(name);
      if (val == 0 ) {
          cout &lt;&lt; val &lt;&lt; " Not Found " &lt;&lt; endl;
      }
      else {
          cout &lt;&lt; val &lt;&lt; "\t" &lt;&lt; ht-&gt;data &lt;&lt; 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 &lt;&lt; ht;
  
     system("pause");
     return 0;
  }
  
  
  int hash(string val) {
      int key;
      key = val % SIZE;
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>Any help will be highly appreciated.</p>
  
  <p>Vish</p>