December 2018
Intermediate to advanced
702 pages
20h 9m
English
Functions can also be marked to indicate whether they will throw an exception. More details about exceptions will be given in Chapter 7, Diagnostics and Debugging, but there are two syntaxes you need to be aware of.
Earlier versions of C++ allowed you to use the throw specifier on a function in three ways: firstly, you can provide a comma separated list of the types of the exceptions that may be thrown by code in the function; secondly, you can provide an ellipsis (...) which means that the function may throw any exception; and thirdly, you can provide an empty pair of parentheses, which means the function will not throw exceptions. The syntax looks like this:
int calculate(int param) throw(overflow_error) { // do ...Read now
Unlock full access