Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.
try is a keyword to mark a try-block, in which an exception might be thrown. The exception can be caught by the subsequent catch-block.
The code below shows the function CanLexicalCast, which returns true if a certain std::string can be converted to another data type (an int, for example). The risky operation, the conversion, is put in the try-block.
#include <cassert> |
Minimize the use of try-blocks [1].
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.