title: Size of struct with vector
body: <p>I am trying to find the difference in size from a struct with vector of object and struct with a vector of object pointers.</p>
  
  <p>The code I have written shows that size of the both structs are the same even in theory at least based their content they should be different.</p>
  
  <p>What would be the correct way of finding the correct size of a struct based on it's contents?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  using namespace std;
  
  struct Song{
      string Name;
      string Artist;
  };
  
  struct Folder{
      vector&lt;Song*&gt; list;
  };
  
  struct Library{
      vector&lt;Song&gt; songs;
  };
  
  int main(int argc, const char * argv[]) {
  
      Library library;
      Folder favorites;
      Folder recentPurchaces;
  
      library.songs.push_back(Song{"Human After All", "Daft Punk"});
      library.songs.push_back(Song{"All of my love", "Led Zepplin"});
  
  
      favorites.list.push_back(&amp;library.songs[0]);
      favorites.list.push_back(&amp;library.songs[2]);
  
  
      cout &lt;&lt; "Size of library: " &lt;&lt; sizeof(library) &lt;&lt; endl;
      cout &lt;&lt; "Size of favorites: " &lt;&lt; sizeof(favorites) &lt;&lt; endl;
  
  
  
      return 0;
  }
  </code></pre>