Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does catch(...) does in C++?

 
k. mahesh kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your Reply. Thanks in advance
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Catches everything.
 
k. mahesh kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you please tell me in what way it differ from catch(exception e){}
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
catch(MyException e) catches only exception of type MyException. catch(...) catches other exception as well.
 
k. mahesh kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Christophe Verré
 
Anand Hariharan
Rancher
Posts: 272
C++ Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Christophe Verré wrote:catch(MyException e) catches only exception of type MyException. catch(...) catches other exception as well.


One usually catches exceptions by (const) reference. It is very rare and (when seen in production code) often questionable if one wanted to catch an exception by value. It will needlessly trigger the copy constructor of the exception object, and considering that one is trying to handle an exception, one doesn't want other things in the way that could independently raise exceptions of their own.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic