|
Syntax 17.9 : Try
Block
try
{ statements
}
catch (type_name1 variable_name1)
{
statements
}
catch (type_name2 variable_name2)
{
statements
}
...
catch (type_namen variable_namen)
{
statements
}
| Example: |
try
{
List staff = read_list();
process_list(staff);
}
catch(logic_error& e)
{
cout << "Processing error " << e.what() << "\n";
}
|
| Purpose: |
Provide one or more handlers for types of
exceptions that may be thrown when executing a block of
statements. |
|