Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!sdd.hp.com!hplabs!hpcc05!hpcuhb!hpcllla!hpclove!mnm From: mnm@hpclove.HP.COM (Michey Mehta) Newsgroups: comp.std.c++ Subject: Question about exception handling Message-ID: <60060001@hpclove.HP.COM> Date: 30 Oct 90 19:44:24 GMT Organization: Hewlett Packard Calif. Language Lab Lines: 52 Hi, This is a request for clarification about the exception handling chapter in the ARM. Consider the following example: ////////////////////////////////////////////// class base { public: virtual void fixit(){}; }; class derived : base { public: virtual void fixit(){}; }; void func() { base* object = new derived; throw(*object); } main(){ try { func(); } catch(derived obj){ obj.fixit(); } catch(base obj){ obj.fixit(); } } ////////////////////////////////////////////// The question is: should derived::fixit be invoked or base::fixit? The ARM says on page 356 "A throw-expression initializes a temporary object of the static type of the operand of throw and uses that temporary to initialize the appropriately-typed variable in the handler". 1. Since the ARM says *static type*, can we cut the object back to being a "base" object? 2. In that case, should we fall into the "catch (base obj)" ? 3. If so, isn't the vtbl entry for obj still pointing to derived::fixit, which could lead to problems? Michey Mehta Hewlett-Packard California Language Lab. Internet: mnm@hpda.hp.com Phone : (408) 447-5740 UUCP: ...!hplabs!hpda!mnm