TITLE: catching exceptions by value PROBLEM: clgonsal@undergrad.math.uwaterloo.ca (Carl Laurence Gonsalves) I'm having a problem with derived exceptions [...] #include class BaseExcept { public: virtual void print(){ cout << "Base\n"; } }; class SubExcept : BaseExcept { public: void print(){ cout << "Sub\n"; } }; int main(){ try{ throw SubExcept(); cout << "not caught"; } catch( BaseExcept v ) { v.print(); } } RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 3 Sept 95 SubExcept is privately derived from BaseExcept, so there is no implicit conversion, and thus no available handler. Make BaseExcept publicly-derived and it should work. In addition, since you are catching the exception by value, the caught exception will always be "sliced" down to the base class, no matter what was thrown. You probably want to catch the exception by reference. [ I think its bad programming practice to catch exceptions by value. You never should assume that derived implementations will always throw the same exception type. -adc ]