title: Memory allocation when declaring a series of class objects in C++
body: <pre class="lang-cpp prettyprint-override"><code>class Data {
      double a, b, c;
  };
  
  int main() {
      Data x, y, z;
      cout &lt;&lt; sizeof(x) &lt;&lt; endl;
      cout &lt;&lt; &amp;x &lt;&lt; &quot; &quot; &lt;&lt; &amp;y &lt;&lt; &quot; &quot; &lt;&lt; &amp;z &lt;&lt; endl;
  }
  </code></pre>
  <p>The output of the above code was:</p>
  <pre><code>24
  0x7ffd911f5640 0x7ffd911f5660 0x7ffd911f5680
  </code></pre>
  <p><strong>Here's my question:</strong> The Data class object needs only 24 bytes of space, then why the compiler allocates 32 bytes (memory spaces between <code>0x7ffd911f5640</code> and <code>0x7ffd911f5660</code>) for each object instead?</p>