Because there are three objects ;)
Forget about that... I only get two objects... I thought you were surprised to see a destructor without a constructor, which would make sense since you don't implement your copy constructors. When I compile your code I see one object created (1 base & 1 derived ctor call) and two destroyed (2 base & 2 derived dtor calls). When I compile this here I see two objects created and two destroyed, as expected.
Thanks for the reply ,
Putting the Copy contructors solves the problem, but my original posted code
On VC++ 2008 windows platform gives me 2 ctor( 1 base and 1 derived) and 6 dtor output statements. I don't have any idea about that.
try { /*...*/ }
catch( derived & ex ) { /*...*/ }
catch( base & ex ) { /*...*/ }
//...
Remember that constructors can throw!
Also, it appears that you're writing your own exception class very similar to std::exception. Consider always using std::exception as a virtual base for your exception classes. It is a very familiar base for other developers, library implementations, etc., and the virtual keyword prevents the future diamond problem if two of your exception classes are ever both inherited into a single subclass.