title: what is the size of an enum type data in C++?
body: <p>This is a C++ interview test question not homework. </p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  enum months_t { january, february, march, april, may, june, july, august, september,    
    october, november, december} y2k;
  
   int main ()
    {
      cout &lt;&lt; "sizeof months_t is  " &lt;&lt; sizeof(months_t) &lt;&lt; endl;
      cout &lt;&lt; "sizeof y2k is  " &lt;&lt; sizeof(y2k) &lt;&lt; endl;
      enum months_t1 { january, february, march, april, may, june, july, august,    
         september, october, november, december} y2k1;
      cout &lt;&lt; "sizeof months_t1 is  " &lt;&lt; sizeof(months_t1) &lt;&lt; endl;
      cout &lt;&lt; "sizeof y2k1 is  " &lt;&lt; sizeof(y2k1) &lt;&lt; endl;
   }
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>sizeof months_t is  4<br>
    sizeof y2k is  4<br>
    sizeof months_t1 is  4<br>
    sizeof y2k1 is  4  </p>
  </blockquote>
  
  <p>Why is the size of all of these 4 bytes? Not 12 x 4 = 48 bytes?<br>
  I know union elements occupy the same memory location, but this is an enum.</p>