title: Initializing private member variables of a class
body: <p>I apologize in advance because some of my verbiage may not be 100% correct. </p>
  
  <p>I will have a class like this: </p>
  
  <pre><code>class ClassName {
  private:
      AnotherClass class2;
  public:
    ClassName();
    ~ClassName();
  ...
  </code></pre>
  
  <p>In the constructor of this class, among other things, I put the line            </p>
  
  <pre><code>ClassName::ClassName() {
      AnotherClass class2; 
  }
  </code></pre>
  
  <p>Which is how I thought you were supposed to initialize objects in C++, however I was noticing (through GDB) that two AnotherClass objects were being created. Once on the Constructor definition then again on my initialization line. What is the reasoning behind this? What if I wanted to use a more complicated constructor like <code>AnotherClass(int a, int b)</code>, would it create a temporary object then create the correct one shortly after? </p>