...
In this non-compliant code example, the first handler will catch all exceptions of class B
, as well as exceptions of class D
, since they are also of class B
. Consequently the second handler will not catch any exceptions.
Code Block | ||||
---|---|---|---|---|
| ||||
// classes used for exception handling class B {}; class D: public B {}; // ... Using the classes from above try { // ... } catch (B &b) { // ... } catch (D &d) { // ... } |
...
In this compliant solution, the first handler will catch all exceptions of class D
, and the second handler will catch all the other exceptions of class B
.
Code Block | ||||
---|---|---|---|---|
| ||||
// classes used for exception handling class B {}; class D: public B {}; // ... Using the classes from above try { // ... } catch (D &d) { // ... } catch (B &b) { // ... } |
...