/*
the code below prints copy constructor called three times , i can trace 2 times , one at throw in myfunction and one at catch(A e) in main .... can somebody explain the third
*/
Code:#include <iostream> #include <exception> using namespace std; class A{ int a; public: A(){ } A(A& gaurav){ a = gaurav.a; cout<<"copy constructor called \n"; } }; void myfunction() { A b; cout<<"here 1\n"; throw b; } int main () { try { myfunction(); } catch (int e) { cout<<e; } catch(A e) { cout<<"here"; } return 0; }