Matching between exceptions thrown and caught (C++
only)
An argument in the catch argument of a handler matches an argument in the assignment_expression of the throw expression (throw argument) if any
of the following conditions is met:
- The catch argument type matches the type of the thrown object.
- The catch argument is a public base class of the thrown class object.
- The catch specifies a pointer type, and the thrown object is a pointer
type that can be converted to the pointer type of the catch argument by standard
pointer conversion.
Note:
If the type of the thrown object is const or volatile, the catch argument must also be a const or volatile for a match to occur. However, a const, volatile, or reference type catch argument can match a nonconstant, nonvolatile,
or nonreference object type. A nonreference catch argument type matches a
reference to an object of the same type.
Related information