why destructor called twice when exception is thrown?
<p>I am very confused why the destrctor is called twice when excpetion is thrown and which point they are called??</p>

<pre><code>#include &lt;iostream&gt; 
using namespace std;
class base
{
 public:
     base(){cout&lt;&lt;"constructor called"&lt;&lt;endl;}
     ~base(){cout&lt;&lt;"destructor called"&lt;&lt;endl;}
};
void fun()
{
     throw base(); //&lt;=- Create temp obj of base, and throw exception

}
int main()
{
    try
    {
        fun();
    }
    catch(...)
    {
        cout&lt;&lt;"handle all exception"&lt;&lt;endl;
    }

}
</code></pre>

<p>following is the output</p>

<pre><code>constructor called
destrctor called
handle all exception
destuctor is called
</code></pre>

<p>But when i added the copy constructor, it never called but destructor called only once so what's happening????</p>

<pre><code>#include &lt;iostream&gt; 
using namespace std;
class base
{
 public:
     base(){cout&lt;&lt;"constructor called"&lt;&lt;endl;}
     ~base(){cout&lt;&lt;"destructor called"&lt;&lt;endl;}
     base (base &amp;obj){cout&lt;&lt;"copy constructor called"&lt;&lt;endl;}
};
void fun()
{
     throw base(); //&lt;=- Create temp obj of base, and throw exception
}
int main()
{
    try
    {
        fun();
    }
    catch(...)
    {
        cout&lt;&lt;"handle all exception"&lt;&lt;endl;
    }

}
</code></pre>

<p>output:</p>

<pre><code>constructor called
handle all exception
destrctor called
</code></pre>
