title: Having trouble understanding C++ constructors and destructors and move/copy semantics
body: <p>I have the following program where I test the order of constructor and destructor calls and I was surprised by the output.</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;utility&gt;
  
  
  class Doctor {
      public:
      Doctor(){
          std::cout &lt;&lt; &quot;Doctor Creation\n&quot;;
      }
  
      ~Doctor(){
          std::cout &lt;&lt; &quot;Doctor DeCreation\n&quot;;
      }
  };
  
  
  class Nurse{
      public:
      int op = 0;
      Nurse(){
          std::cout &lt;&lt; &quot;Nurse Creation\n&quot;;
      }
  
      ~Nurse(){
          std::cout &lt;&lt; &quot;Nurse &quot; &lt;&lt;  op &lt;&lt; &quot; DeCreation\n&quot;;
      }
  };
  
  class Hospital{
      private:
          Doctor doc;
          Nurse nurse;
      public:
      Hospital(){
          std::cout &lt;&lt; &quot;Hospital Creation\n&quot;;
      }
      ~Hospital(){
          std::cout &lt;&lt; &quot;Hospital DeCreation\n&quot;;
      }
  
      void operate(){
          std::cout &lt;&lt; &quot;Hospital Operation\n&quot;;
          nurse.op++;
          std::cout &lt;&lt; &amp;this-&gt;nurse &lt;&lt; &quot; &quot; &lt;&lt; nurse.op &lt;&lt; &quot;\n&quot;;
          reset_hospital();
          std::cout &lt;&lt; &amp;this-&gt;nurse &lt;&lt; &quot; &quot; &lt;&lt; nurse.op &lt;&lt; &quot;\n&quot;;
      }
  
      void reset_hospital(){
          std::cout &lt;&lt; &amp;this-&gt;nurse &lt;&lt; &quot; &quot; &lt;&lt; nurse.op &lt;&lt; &quot;\n&quot;;
          nurse = std::move(Nurse());
          doc = std::move(Doctor());
      }
  };
  
  int main(){
      Hospital hospital;
      hospital.operate();
  }
  </code></pre>
  <p><a href="https://godbolt.org/z/bf8KbqsTK" rel="nofollow noreferrer">https://godbolt.org/z/bf8KbqsTK</a></p>
  <p>The output is:</p>
  <pre><code>Doctor Creation
  Nurse Creation
  Hospital Creation
  Hospital Operation
  0x7fff2316866c 1
  0x7fff2316866c 1
  Nurse Creation
  Nurse 0 DeCreation
  Doctor Creation
  Doctor DeCreation
  0x7fff2316866c 0
  Hospital DeCreation
  Nurse 0 DeCreation
  Doctor DeCreation
  </code></pre>
  <p>Shouldn't it be <code>Nurse 1 DeCreation</code> on the std::move operation? The current object is destroyed and replaced by the new one? Or for some reason, is it copying instead of moving?</p>
  <p>I'm so confused.</p>