title: Why is the destructor of the class called twice? shared_ptrs
body: <pre><code> class Class {
   public:
       Class()  {std::cout &lt;&lt; "Constructor" &lt;&lt; '\n';}
       ~Class() {std::cout &lt;&lt; "Destructor" &lt;&lt; '\n';}
   }; 
  
   int main() {
       std::cout&lt;&lt;"\nNew shared_ptr:\n";
       Class C;
       std::shared_ptr&lt;Class&gt; ptr(&amp;C);
   }
  </code></pre>
  
  <p>After running I have:</p>
  
  <pre><code>New shared_ptr: 
  Constructor 
  Destructor 
  Destructor
  </code></pre>
  
  <p>Why is that? Why is the destructor called twice? </p>