Hi,

How come I am seeing destructor getting called twice in the following code?

struct A 
{ 
     A() { 
        cout << "A()\n"; 
     } 
     ~A() { 
        cout << "~A()\n"; 
     } 
};
int main()
{
     try {
        throw A();
     } catch (const A& a) {
        cout << "caught\n"; 
     }
} 
 
Output:
 
A()
~A()
caught
~A()

Tried on codepad.org


      The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. 
http://in.yahoo.com/

[Non-text portions of this message have been removed]

Reply via email to