title: Default initialization confusion
body: <p>In my C++ Primer, 5th Edition, they say on page 43 about default initialization (emphasis mine):</p>
  
  <blockquote>
    <p>The value of an object of built-in type that is not explicitly initialized depends on where it is defined. <strong>Variables defined outside any function body are initialized to zero.</strong></p>
  </blockquote>
  
  <p>Later, on page 73, they define a new class like this:</p>
  
  <pre><code>struct Sales_data {
    std::string bookNo;
    unsigned units_sold = 0;
    double revenue = 0.0;
  };
  </code></pre>
  
  <p>This is supposed to provide an example of the new standard's in-class initializers. In this case, <code>units_sold</code> and <code>revenue</code> will be initialized to zero. If they are not, they say, the variables will be default-initialized.</p>
  
  <p>But this is my question: What is the point of this in-class initialization? What's wrong with letting them just default-initialize? The reason I ask is that they already mentioned that <strong>variables defined outside any function body are initialized to zero</strong>, and in this case, these variables are not inside any function - they are in a class definition. So the default-initialization should initialize these variables to zero, shouldn't it?</p>