title: Does an unused member variable take up memory?
body: <p>Does initializing a member variable and not referencing/using it further take up RAM during runtime, or does the compiler simply ignore that variable?</p>
  
  <pre><code>struct Foo {
      int var1;
      int var2;
  
      Foo() { var1 = 5; std::cout &lt;&lt; var1; }
  };
  </code></pre>
  
  <p>In the example above, the member 'var1' gets a value which is then displayed in the console. 'Var2', however, is not used at all. Therefore writing it to memory during runtime would be a waste of resources. Does the compiler take these kinds of situations into an account and simply ignore unused variables, or is the Foo object always the same size, regardless of whether its members are used?</p>