4
The action provided by the default terminate handler can be disastrous in some situations. For example, it may leave files in an unsatisfactory state, or connection to a communications line may be left open. In such cases, you’d want to make sure that things are tidied up properly before the program ends. You can do this by replacing the default terminate handler function with your own version by calling the Standard Library function std::set_terminate(), as illustrated in Figure 15-3. The set_terminate()function accepts an argument of type terminate_handler, and returns a value of the same type. This type is defined in the exceptionheader file as o gotoor a returnstatement, execution continues with the statement immediately following the last catchblock for the tryblock. Once a handler bject is used to initialize the parameter for the catchblock that is selected to handle the exception. A catchblock is also a statement block, so when a catchblock has finished executing, all automatic objects that Step2 : 2jnkjrncjernvcenvenv Step 1: gjgjghggksfjheruihvreuivrev\ Step2 : 2jnkjrncjernvcenvenv Step 1: gjgjghggksfjheruihvreuivrev\ Step2 : 2jnkjrncjernvcenvenv Step 1: gjgjghggksfjheruihvreuivrev\ Step2 : 2jnkjrncjernvcenvenv Step 1: gjgjghggksfjheruihvreuivrev\ Step2 : 2jnkjrncjernvcenvenv

Except

Embed Size (px)

DESCRIPTION

KL

Citation preview

Page 1: Except

The action provided by the default terminate handler can be disastrous in some situations. For example, it may

leave files in an unsatisfactory state, or connection to a communications line may be left open. In such cases, you’d

want to make sure that things are tidied up properly before the program ends. You can do this by replacing the default

terminate handler function with your own version by calling the Standard Library function std::set_terminate(),

as illustrated in Figure 15-3. The set_terminate()function accepts an argument of type terminate_handler, and

returns a value of the same type. This type is defined in the exceptionheader file as o

gotoor a returnstatement, execution continues with the statement immediately following the last catchblock for

the tryblock. Once a handler bject is used to initialize the parameter for the catchblock that is selected to handle the exception.

A catchblock is also a statement block, so when a catchblock has finished executing, all automatic objects that

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

are local to it (including the parameter) will be destroyed. Unless you transfer control out of the catchblock using a

Page 2: Except

Because the throwexpression is used to initialize a temporary object — and therefore creates a copy of the

exception — you can throw objectsthat are local to the tryblock, but not pointersto local objects. The copy of the

has been selected for an exception and control has been passed to it, the exception is

considered handled. This is true even if the catchblock his period concentrated on studies relating to natural slope and unit weights of various

types of soils, as well as the semiempirical earth pressure theories. In 1717 a French royal

engineer, HStep2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

his period concentrated on studies relating to natural slope and unit weights of various

types of soils, as well as the semiempirical earth pressure theories. In 1717 a French royal

engineer, HStep2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Page 3: Except

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Page 4: Except

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv

Step 1: gjgjghggksfjheruihvreuivrev\

Step2 : 2jnkjrncjernvcenvenv