title: C++ sizeof Vector is 24?
body: <p>I was just messing around and learning about vectors as well as structs, and at one point, I tried outputting the size of a vector in bytes. Here's the code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  struct Foo{
      std::vector&lt;int&gt; a;
  };
  
  int main()
  {
      using std::cout; using std::endl;   
  
      Foo* f1 = new Foo;
  
      f1-&gt;a.push_back(5);
      cout &lt;&lt; sizeof(f1-&gt;a) &lt;&lt; endl;
      cout &lt;&lt; sizeof(f1-&gt;a[0]) &lt;&lt; endl;
  
      delete[] f1;
  }
  </code></pre>
  
  <p>The output is <code>24</code> and <code>4</code>.</p>
  
  <p>Obviously the second line printed 4, because that is the size of an int. But why exactly is the other value 24? Does a vector take up 24 bytes of memory? Thanks!</p>