title: global struct with vector member
body: <p>Why is this simple block of code not compiling</p>
  
  <pre><code>//using namespace std;
  struct test {
      std::vector&lt;int&gt; vec;
  };
  test mytest;
  
  void foo {
      mytest.vec.push_back(3);
  }
  
  int main(int argc, char** argv) {
     cout &lt;&lt; "Vector Element" &lt;&lt; mytest.vec[0] &lt;&lt; endl;
     return 0;
  }
  </code></pre>
  
  <p>I get the following errors:</p>
  
  <pre><code>vectorScope.cpp:6:5: error: ‘vector’ in namespace ‘std’ does not name a type
  
  vectorScope.cpp:11:6: error: variable or field ‘foo’ declared void
  
  vectorScope.cpp:11:6: warning: extended initializer lists only available with -std=c++0x or -std=gnu++0x [enabled by default]
  
  vectorScope.cpp:12:12: error: ‘struct test’ has no member named ‘vec’
  
  vectorScope.cpp:12:28: error: expected ‘}’ before ‘;’ token
  
  vectorScope.cpp:13:1: error: expected declaration before ‘}’ token
  </code></pre>
  
  <p>Thank you,</p>
  
  <p>Mustafa</p>