title: try and catch in C++ - how many objects are created
body: <p>Consider the following code: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  class Box{
      public: 
          std::string show(){
              std::cout&lt;&lt;"Box show executed"&lt;&lt;std::endl;
              return "msg";
          };
  
          ~Box(){
              std::cout&lt;&lt;"Box destructor is executed"&lt;&lt;std::endl;
          };
  };
  
  int main(){
  
      try{
          Box obj;
          std::cout&lt;&lt;"Coming here"&lt;&lt;std::endl;
          throw obj;
      }
      catch(Box msg){
          std::cout&lt;&lt;"I have caught the exception: \n"&lt;&lt;msg.show()&lt;&lt;std::endl;
      }
  
  }
  </code></pre>
  
  <p>In GCC compiler the output is: </p>
  
  <pre><code>Coming here
  Box destructor is executed
  Box show executed
  I have caught the exception:
  msg
  Box destructor is executed
  Box destructor is executed
  </code></pre>
  
  <p>My confusions are:    </p>
  
  <ol>
  <li><p>The statement prints are very confusing, why is the "Box show
  executed" printing before the "I have caught the exception" line?</p></li>
  <li><p>There are three destructors called, How is this possible when only
      two objects are created, one the Box object in the try and the temp
      object in the try which is passed to the catch block?</p></li>
  </ol>