5.6.2. The try
Block
The general form of a try
block is
try { program-statements} catch (exception-declaration) { handler-statements} catch (exception-declaration) { handler-statements} // . . .
A try
block begins with the keyword try
followed by a block, which, as usual, is a sequence of statements enclosed in curly braces.
Following the try
block is a list of one or more catch
clauses. A catch
consists of three parts: the keyword catch
, the declaration of a (possibly unnamed) object within parentheses (referred to as an exception declaration), and a block. When a catch
is selected to handle an exception, the associated block is executed. Once the catch
finishes, execution continues with the statement immediately following the last ...
Get C++ Primer, Fifth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.