Path: utzoo!attcan!uunet!cimshop!davidm From: cimshop!davidm@uunet.UU.NET (David S. Masterson) Newsgroups: comp.lang.c++ Subject: Re: Exception handling Message-ID: Date: 5 Oct 90 17:06:42 GMT References: <958@zinn.MV.COM> Sender: davidm@cimshop.UUCP Distribution: comp Organization: Consilium Inc., Mountain View, California. Lines: 60 In-reply-to: mjv@objects.mv.com's message of 3 Oct 90 15:43:09 GMT In article <958@zinn.MV.COM> mjv@objects.mv.com (Michael J. Vilot) writes: [I] 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 } } Would it be valid to add a call to another function (say myf()) at the end of main() where its defined as below? int myf() { try { B b; } catch(X) { // something different than previous catch(X) } catch(Y) { // something different than previous catch(Y) } } Point is, is it valid to reset how exceptions are processed? -- ==================================================================== David Masterson Consilium, Inc. uunet!cimshop!davidm Mtn. View, CA 94043 ==================================================================== "If someone thinks they know what I said, then I didn't say it!"