title: Data structure alignment: why are array of char and std::string different
body: <p>Known that <code>sizeof(std::string)</code> is 8, <code>sizeof(int)</code> is 4.<br></p>
  
  <pre><code>class Test1
  {
  int i;            // 4
  std::string str;  // 8
  };
  </code></pre>
  
  <p><code>sizeof(Test1)</code> is 16, because 8 = N1 * 4 and 16 = N2 * 8. (N1 and N2 are natural numbers)</p>
  
  <p>However, if I replace <code>std::string</code> with <code>char [8]</code> as below:<br></p>
  
  <pre><code>class Test2
  {
  int i;       // 4
  char ch[8];  // 8
  };
  </code></pre>
  
  <p>I don't know why <code>sizeof(Test2)</code> gives me 12.</p>