Thread View: comp.std.c++
1 messages
1 total messages
Started by Ross Dargahi (MERC)
Thu, 14 Dec 1995 23:28
Nested Exception Classes
Author: Ross Dargahi (MERC)
Date: Thu, 14 Dec 1995 23:28
Date: Thu, 14 Dec 1995 23:28
63 lines
2647 bytes
2647 bytes
Consider:
class BaseException {};
class BaseClass
{
public:
class Exception: public BaseException {};
class BaseException1: public Exception {};
};
class DerivedClass1: public BaseClass
{
public:
class Exception: public Base::Exception {};
class Derived1Exception1: public Exception {};
};
class DerivedClass2: public DerivedClass1
{
public:
class Exception: public DerivedClass1::Exception {};
class Derived2Exception1: public Exception {};
};
Do I really need the class Exception classes (the ones named Exception ) in
DerivedClass1 and DerivedClass2 (The only reason I can think of doing this is
if I wanted to added class specific information to the class e.g. the name of
the class actually throwing the exception) since I will have access to class
Exception by inheritance from BaseClass ?
Is it legal to in fact have the class Exception classes in the derived
classes or should this be an error (my guess is it should be legal since
BaseClass::Exception is in a different scope than Derived1Class1::Exception
etc...)
If I only have class Exception defined in BaseClass and in some method of
class DerivedClass2 I throw a Derived2Exception1 will all of the following
catch clauses catch the exception (methinks yes) ?
catch (DerivedClass2::Exception)
catch (DerivedClass1::Exception)
catch (BaseClass::Exception)
catch (BaseException)
Cheers
Ross
==============================================================================
Ross Dargahi
Knight-Ridder Information, Inc., email: rossd@dnt.dialog.com
2440 El Camino Real, Tel: 415.254.8124
Mountain View, California 94040, USA. Fax: 415.254.8058
==============================================================================
[ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu.
Contact address: std-c++-request@ncar.ucar.edu. The moderation policy
is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads