Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fixed bg color for compliant code block

...

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
bgColor#FFcccc

// 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
bgColor#FFcccc#ccccff

// classes used for exception handling
class B {};
class D: public B {};

// ... Using the classes from above
try {
 // ...
} catch (D &d) {
 // ...
} catch (B &b) {
 // ...
}

...