title: Dynamic String Array Container Class hangs on runtime at delete[]
body: <p>I am working on an assignment to create a container class for a dynamic array of strings. I know this would be far better done with a std::vector, but that is not the 'pointer' of the assignment.</p>
  
  <p>From what I can tell, my program hangs during the delete [] lineArray step below.</p>
  
  <pre><code>MyBag::MyBag()
  {
      nLines = 0;
      lineArray = new std::string[0] ();
  }
  void MyBag::ResizeArray(int newLength)
  {
      std::string *newArray = new std::string[newLength];
      //create new array with new length
      for (int nIndex=0; nIndex &lt; nLines; nIndex++)
      {
          newArray[nIndex] = lineArray[nIndex];
          //copy the old array into the new array
      }
      delete[] lineArray; //delete the old array
      lineArray = newArray; //point the old array to the new array
      nLines = newLength; //set new array size
  }
  void MyBag::add(std::string line)
  {
      ResizeArray(nLines+1); //add one to the array size
      lineArray[nLines] = line; //add the new line to the now extended array
      nLines++;
  }
  </code></pre>
  
  <p>The entire program is here <a href="http://pastebin.com/KnL4XmAw" rel="nofollow">http://pastebin.com/KnL4XmAw</a></p>