c++ - try-catch
- K Sergey (26/26) Oct 25 2002 What should normally happens in the following C++ code?
- Matthew Wilson (8/34) Oct 31 2002 Should call unexpected() (or it may be terminate() - is late here ... ) ...
What should normally happens in the following C++ code? void ups() { int a=0,b;b/=a; } // couse divide by 0 exception class A { public: ~A() { ups(); } }; void do_some() { try { A a; ups(); } catch (...) { } } void main() { try { do_some(); } catch(...) { } }
Oct 25 2002
Should call unexpected() (or it may be terminate() - is late here ... ) as you cannot throw within an unwind. This is one of the reasons that destructors should not throw exceptions. I'm pretty sure it's terminate(), since unexpected() is to do with mismatch wrt ex-specs. Matthew "K Sergey" <K_member pathlink.com> wrote in message news:apbgm1$2rrf$1 digitaldaemon.com...What should normally happens in the following C++ code? void ups() { int a=0,b;b/=a; } // couse divide by 0 exception class A { public: ~A() { ups(); } }; void do_some() { try { A a; ups(); } catch (...) { } } void main() { try { do_some(); } catch(...) { } }
Oct 31 2002