title: Overloaded [] operator for hash table to a vector
body: <p>I am working on a simple hash table in C++. I have methods to insert, delete, and search the hash table for the specified key. I know that the C++ map STL container can handle my situation, but I would kind of like to code my own as an educational exercise. </p>
  
  <p>Basically I have a hash table that will take a single string and map it to a vector of other strings. This is easy to do in a method because calling a .Add() or .Delete() will behave as expected. I would however like to create an overloaded [] operator to the class that is able to do these operations on the vector. </p>
  
  <p>For example, if I want to add an item to the vector I can write something like this: </p>
  
  <pre>
       hashTable[string1] = newString;
  </pre>
  
  <p>This will set the new string as a member of my vector. The same can be said for delete and search. </p>
  
  <pre>
      hashTable[string1] = "";
      cout &lt;&lt; hashTable[string1] &lt;&lt; endl;
  </pre>
  
  <p>My major problem is that I do not know how to overload the <code>[]</code> operator to gain this functionality. I have this function coded up right now. It works on a basic 1 to 1 string match, but not on a string to vector match. </p>
  
  <pre>
      //Return a reference to a vector to update then reassign?
  
          vector& HashClass::operator[](const string index)
          {
             assert(size &gt;= 0 && size &lt; maxSize); 
             Hash(key);
             return hashTable[index];     
          }
  </pre> 
  
  <p>I think I'm most stuck on the idea of having a vector return that later needs to be assigned. As the user, I would find this kludgy. </p>