title: How memory is allocated for private and public members of the class
body: <p>In a class, are private members allocated in separate memory from public members, or all members allocated in the sequence of their definition?</p>
  
  <p>For example, </p>
  
  <pre><code>class A { 
  
  private:  
      int a1;
      int a2:3;  
  public:  
      int z;  
      int a3:2;  
      int a4:5;  
  private:
      int a5:2;
  }
  </code></pre>
  
  <p>Are <code>a1</code>, <code>a2</code>, and <code>a5</code> clubbed together for memory allocation or is it simply <code>a1</code>, <code>a2</code>, <code>a3</code>, <code>a4</code>, <code>a5</code> ?  </p>
  
  <p>If clubbing happens it might change the size of the class in case of bit fields.</p>