title: C++ vector error (Visual C++ 2008 Express Edition)
body: <p>I'm trying to run this small program in <code>Visual C++ 2008 Express Edition</code>:</p>
  
  <pre><code>#include &lt;vector&gt;
  int main(){
  vector&lt;bool&gt; features(4,false);
  for(vector&lt;bool&gt;::iterator i = features.begin(); i != features.end(); i++){
  cout&lt;&lt;features[i];
  }
  }
  </code></pre>
  
  <p>When I do that I get the following:</p>
  
  <pre><code>   1&gt;------ Build started: Project: SFS, Configuration: Debug Win32 ------
  1&gt;Compiling...
  1&gt;SFS.cpp
  1&gt;.\SFS.cpp(1) : warning C4627: '#include &lt;vector&gt;': skipped when looking for precompiled header use
  1&gt;        Add directive to 'stdafx.h' or rebuild precompiled header
  1&gt;.\SFS.cpp(14) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
  1&gt;Build log was saved at "file://c:\Users\Ola\Documents\Visual Studio 2008\Projects\SFS\SFS\Debug\BuildLog.htm"
  1&gt;SFS - 1 error(s), 1 warning(s)
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>I also get the following error message:</p>
  
  <p><img src="https://i.stack.imgur.com/mr5F5.png" alt="enter image description here"></p>
  
  <p><strong>EDIT(1)</strong></p>
  
  <p>After I add <code>#include "stdafx.h"</code>, I get the following:</p>
  
  <pre><code>1&gt;------ Build started: Project: SFS, Configuration: Debug Win32 ------
  1&gt;Compiling...
  1&gt;SFS.cpp
  1&gt;.\SFS.cpp(5) : error C2065: 'vector' : undeclared identifier
  1&gt;.\SFS.cpp(5) : error C2062: type 'bool' unexpected
  1&gt;.\SFS.cpp(6) : error C2065: 'vector' : undeclared identifier
  1&gt;.\SFS.cpp(6) : error C2062: type 'bool' unexpected
  1&gt;.\SFS.cpp(6) : error C2039: 'iterator' : is not a member of '`global namespace''
  1&gt;.\SFS.cpp(6) : error C2065: 'i' : undeclared identifier
  1&gt;.\SFS.cpp(6) : error C2065: 'features' : undeclared identifier
  1&gt;.\SFS.cpp(6) : error C2228: left of '.end' must have class/struct/union
  1&gt;        type is ''unknown-type''
  1&gt;.\SFS.cpp(6) : error C2065: 'i' : undeclared identifier
  1&gt;.\SFS.cpp(6) : error C2143: syntax error : missing ';' before ')'
  1&gt;.\SFS.cpp(6) : error C2143: syntax error : missing ';' before ')'
  1&gt;.\SFS.cpp(6) : error C2143: syntax error : missing ';' before '{'
  1&gt;.\SFS.cpp(7) : error C2065: 'cout' : undeclared identifier
  1&gt;.\SFS.cpp(7) : error C2065: 'features' : undeclared identifier
  1&gt;.\SFS.cpp(7) : error C2065: 'i' : undeclared identifier
  1&gt;Build log was saved at "file://c:\Users\Ola\Documents\Visual Studio 2008\Projects\SFS\SFS\Debug\BuildLog.htm"
  1&gt;SFS - 15 error(s), 0 warning(s)
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>In addition to the same error message box.</p>
  
  <p><strong>EDIT(2)</strong></p>
  
  <p>After I add <code>#include&lt;iostream&gt;</code> and use <code>std::cout</code>, I get the following:</p>
  
  <pre><code>1&gt;------ Build started: Project: SFS, Configuration: Debug Win32 ------
  1&gt;Compiling...
  1&gt;SFS.cpp
  1&gt;.\SFS.cpp(1) : warning C4627: '#include &lt;iostream&gt;': skipped when looking for precompiled header use
  1&gt;        Add directive to 'stdafx.h' or rebuild precompiled header
  1&gt;.\SFS.cpp(2) : warning C4627: '#include &lt;vector&gt;': skipped when looking for precompiled header use
  1&gt;        Add directive to 'stdafx.h' or rebuild precompiled header
  1&gt;.\SFS.cpp(16) : fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source?
  1&gt;Build log was saved at "file://c:\Users\Ola\Documents\Visual Studio 2008\Projects\SFS\SFS\Debug\BuildLog.htm"
  1&gt;SFS - 1 error(s), 2 warning(s)
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>In addition to the same error message box.</p>
  
  <p>Why is that? How can I solve this out?</p>
  
  <p>Thanks.</p>