title: Variable length array of non-POD element type 'string' (aka 'basic_string<char>') c++
body: <p>I get this error in my c++ code Variable length array of non-POD element type <code>string</code> (aka <code>basic_string&lt;char&gt;</code>).</p>
  
  <pre><code>string words[numWords];
  </code></pre>
  
  <p>If I get rid of numWords and enter a number this works fine but if i put the same number in a variable it gives me the <code>Variable length array of non-POD element type 'string' (aka 'basic_string&lt;char&gt;')</code> error, I have done it this way before and it worked in visual studio but I have now tried it in Xcode and it doesn't work. I have tried using vectors but I can't get them sot store any data and they just come back blank.</p>
  
  <p>For those who asked this is my vector code should all be there</p>
  
  <pre><code>char ch;
  
  ifstream repFile("//Users//bobthemac//Documents//c++asignment//c++asignment//test1.txt");
  
  while(repFile.get(ch))
  {
      if(ch == ' ' || ch == '\n' || ch == '\t')
      {
          numWords++;
      }
  }
  
  vector&lt;string&gt; words (numWords);
  
  while(repFile &gt;&gt; x)
      words.push_back(x);
  repFile.close();
  </code></pre>