title: Why different behaviour of synthesized default constructor for static and local variable of user defined class type?
body: <p>In the sample program below,</p>
  <p>Why is the output different for static &amp; automatic variable of user defined class type ?</p>
  <pre><code>/* test.cpp */
  
  /* SalesData Class */
  class SalesData {
  
      public:
          SalesData() = default;
          // other member funcations
      private:
          std::string bookNo;
          unsigned int unitsSold;
          double revenue;
  
  };
  
  /*
   * Prints the SalesData object
   */
  std::ostream&amp; print(std::ostream &amp;os, const SalesData &amp;item) {
      os &lt;&lt; &quot;ISBN :\'&quot; &lt;&lt; item.isbn() &lt;&lt; &quot;\', Units Sold :&quot; &lt;&lt; item.unitsSold
          &lt;&lt; &quot;, Revenue :&quot; &lt;&lt; item.revenue &lt;&lt; &quot;, Avg. Price :&quot;
          &lt;&lt; item.avgPrice() &lt;&lt; std::endl;
  
      return os;
  }
  
  int main(int argc, char *argv[]) {
      SalesData s;
      static SalesData s2;
  
  
      print(cout, s);
      print(cout, s2);
  
      return 0;
  }
  </code></pre>
  <p>Output of the program is this --</p>
  <pre><code>$ ./test
  ISBN :'', Units Sold :3417894856, Revenue :4.66042e-310, Avg. Price :1.36352e-319
  ISBN :'', Units Sold :0, Revenue :0, Avg. Price :0
  </code></pre>
  <p>How is static changing the scene in synthesized default constructor ?</p>