Oh got it... the damn copy constructor! Sorry for the trouble guys.
________________________________ From: manish bhatia <[email protected]> To: [email protected] Sent: Thu, 24 December, 2009 11:22:44 PM Subject: [c-prog] destructor getting called twice? 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] The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. http://in.yahoo.com/ [Non-text portions of this message have been removed]
