title: Getting the size of member variable
body: <p>If there is a <a href="http://en.wikipedia.org/wiki/Plain_old_data_structure">POD</a> structure, with some member variables, for example like this:</p>
  
  <pre><code>struct foo
  {
     short a;
     int b;
     char c[50];
     // ...
  };
  </code></pre>
  
  <p>Is there a way to get the size of a member variable in bytes, without creating an object of this type?</p>
  
  <p>I know that this will work:</p>
  
  <pre><code>foo fooObj;
  std::cout &lt;&lt; sizeof( fooObj.a ) &lt;&lt; std::endl;
  std::cout &lt;&lt; sizeof( fooObj.b ) &lt;&lt; std::endl;
  std::cout &lt;&lt; sizeof( fooObj.c ) &lt;&lt; std::endl;
  </code></pre>
  
  <p>Would the following be optimized by the compiler and prevent the construction of an object?</p>
  
  <pre><code>std::cout &lt;&lt; sizeof( foo().a ) &lt;&lt; std::endl;
  </code></pre>