Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!samsung!crackers!jjmhome!zinn!nuucp From: mjv@objects.mv.com (Michael J. Vilot) Newsgroups: comp.lang.c++ Subject: Re: Exception handling Message-ID: <958@zinn.MV.COM> Date: 3 Oct 90 15:43:09 GMT Sender: nuucp@zinn.MV.COM Lines: 42 David Masterson asked for an example of exception handling with constructor failures: int f() throw(X); int g() throw(Y); class A { int a_part; public: A() { a_part = f(); } ... }; class B : public A { int b_part; public: B() /* A() invoked */ { b_part = g(); } ... }; main() { try { B b; } catch(X) { // we get here if f() failed while building b.a_part // b.b_part not attempted } catch(Y) { // we get here if g() failed while building b.b_part // note that if `a_part' had been of a class with a // destructor, then that destructor would have been executed } } [My aplogies to everyone -- my earlier posting re-sent his question, instead of my response.] -- Mike Vilot, ObjectWare Inc, Nashua NH mjv@objects.mv.com (UUCP: ...!decvax!zinn!objects!mjv)