title: How do C++ class members get initialized if I don't do it explicitly?
body: <p>Suppose I have a class with private memebers <code>ptr</code>, <code>name</code>, <code>pname</code>, <code>rname</code>, <code>crname</code> and <code>age</code>.  What happens if I don't initialize them myself? Here is an example:</p>
  <pre><code>class Example {
      private:
          int *ptr;
          string name;
          string *pname;
          string &amp;rname;
          const string &amp;crname;
          int age;
  
      public:
          Example() {}
  };
  </code></pre>
  <p>And then I do:</p>
  <pre><code>int main() {
      Example ex;
  }
  </code></pre>
  <p>How are the members initialized in ex? What happens with pointers? Do <code>string</code> and <code>int</code> get 0-intialized with default constructors <code>string()</code> and <code>int()</code>? What about the reference member? Also what about const references?</p>
  <p>I'd like to learn it so I can write better (bug free) programs. Any feedback would help!</p>