When declaring a function we can limit the exception type it might directly or indirectly throw by appending a throw suffix to the function declaration:
|
|
This declares a function called myfunction which takes one argument of type char and returns an element of type float. The only exception that this function might throw is an exception of type int. If it throws an exception with a different type, either directly or indirectly, it cannot be caught by a regular int-type handler.
If this throw specifier is left empty with no type, this means the function is not allowed to throw exceptions. Functions with no throw specifier (regular functions) are allowed to throw exceptions with any type:
|
|
Comments
Post a Comment
https://gengwg.blogspot.com/