title: Why can I not push an instance of Foo into a static vector stored inside Foo?
body: <pre class="lang-cpp prettyprint-override"><code>#include &lt;string&gt;
  #include &lt;vector&gt;
  using namespace std;
  class Foo {
  public:
      string name = &quot;Guntr&quot;;
      static vector&lt;Foo&gt; names;
  };
  
  int main() {
      Foo myName = Foo();
      Foo::names.push_back(myName);
  }
  </code></pre>
  <p>Why can I not push an instance of Foo into a static vector stored inside Foo?</p>
  <p>I get the following compile error:</p>
  <pre><code>C:\Program Files\JetBrains\CLion 2022.2\bin
  \mingw\bin/ld.exe: CMakeFiles/untitled6.dir/main.cpp.obj:main.cpp:
  (.rdata$.refptr._ZN3Foo5namesE[.refptr.
  _ZN3Foo5namesE]+0x0): undefined reference to `Foo::names'
  </code></pre>
  <p>Is the compiler unable to determine how much memory to allocate the <code>vector&lt;Foo&gt; names</code> array?</p>
  <p>Because the compiler is unhappy with this approach, would it be better to have the vector be a global or be stored in a driver class?</p>