Why doesn\'t the following doesn\'t handle the exception that was rethrown? I tried all the combinations but none of them would show the output in last catch so I\'m confused!>
This should work :
Derived D; try{ try { throw D; } catch ( const Derived &d) { throw; } catch (const Base &b) { cout << "caught!" << endl; } } catch (const Base &b) { cout << "caught here!" << endl; }
As other said, the rethrow will rethrow the same exception out of the catch block.
rethrow