Segfault at string::assign
<p>I'm having difficulty assigning a value to a string. The string is contained in a struct. Here is the full code. It's largely incomplete(I'm trying to get this to work before fixing my iterator)</p>

<p>It fails at operator[]</p>

<p>:</p>

<pre><code>#include &lt;string&gt;
#include &lt;iostream&gt;
#include &lt;vector&gt;

using namespace std;

template &lt;class Key,class Value&gt;
class hashMap
{
  public:
    explicit hashMap( int size = 101 ) : arraySize( size ){
      array.reserve(arraySize+1);
    }
    hashMap(const hashMap &amp; rhs){
      arraySize = rhs.arraySize;
      array.reserve(arraySize);
      for(int i = 0; i &lt; arraySize; i++)
      {
        array[i] = rhs.array[i];
      }
    }
    ~hashMap()
    {
    }
    hashMap &amp; operator=(const hashMap &amp; rhs){
      if (&amp;rhs != this)
      {
        arraySize = rhs.arraySize;
        array.clear();
        array.reserve(arraySize);
        for(int i = 0; i &lt; arraySize; i++)
        {
          array[i] = rhs.array[i];
        }
      }
    }
    Value &amp; operator[](const Key &amp; key)
    {
        unsigned long long pos = hash(key, arraySize);
        unsigned long long quad = 1;
        while (array[pos].active != false &amp;&amp; array[pos].first != key)
        {
          pos += quad;
          pos %= arraySize;
          quad *= 2;
        }
        array[pos].first = key; // FAILS HERE
        array[pos].active = true;
        return array[pos].second;
    }

    struct cell{
      Key first;
      Value second;
      bool active;
      cell(){
        active = false;
      }
    };

    class const_iterator
    {
      public:
        cell operator*()
        {
          return array[pos];
        }
      private:
        int pos;
    };

  private:
    vector&lt;cell&gt; array;
    int arraySize;
    int hash(const std::string &amp; key, int tableSize)
    {
      int hashVal = 0;

      for(int i = 0; i &lt; key.length(); i++)
      {
        hashVal = 37 * hashVal + key[i];
      }

      hashVal %= tableSize;
      if(hashVal &lt; 0)
      {
        hashVal += tableSize;
      }

      return hashVal;
    }
    int hash(int key, int tableSize)
    {
      return key%tableSize;
    }
};
</code></pre>

<p>I would very much appreciate the help!</p>

<p>~A hopeless computer science student</p>
