edited by
1,702 views
1 votes
1 votes

Which of the following are two special functions that are meant for handling exception, that  occur during exception handling itself?

  1. Void terminate () and void unexpected()
  2. Non void terminate () and void unexpected()
  3. Void terminate () and non void unexpected()
  4. Non void terminate () and non void unexpected()
edited by

1 Answer

1 votes
1 votes

Ans: A

Special functions

The exception handling mechanism relies on two functions, terminate() and unexpected(), for coping with errors related to the exception handling mechanism itself.

void terminate()

The function std::terminate() is called:

  • If an exception is thrown but not caught.

  • If the exception handling mechanism finds that the stack is corrupted.

  • If a destructor propagates an exception during stack unwinding due to another exception (i.e. if a destructor throws while uncaught_exception() is true).

The function terminate() calls teminate_handler() which by default calls abort(). The behaviour of terminate() can be altered by supplying a function pointer to set_terminate().

void unexpected()

If a function throws an exception not allowed by its exception specification (see below) then:

  • the stack is unwound for the function

  • the function unexpected() is called.

The function unexpected() calls unexpected_handler() which by default calls terminate(). The behaviour of unexpected() can be altered by supplying a function pointer to set_unexpected().

ref: https://accu.org/index.php/journals/513

Answer:

Related questions

0 votes
0 votes
1 answer
1
go_editor asked Jul 11, 2016
2,343 views
Which of the following mode declaration used in C++ to open a file for input?ios : : appin : : iosios : : fileios : : in
0 votes
0 votes
1 answer
2
go_editor asked Jul 11, 2016
2,459 views
Enumeration is a process ofDeclaring a set of numbersSorting a list of stringsAssigning a legal values possible for a variableSequencing a list of operators
1 votes
1 votes
2 answers
3
go_editor asked Jul 10, 2016
2,367 views
Which API is used to draw a circle?Circle ()Ellipse ()Round Rect ()Pie ()
0 votes
0 votes
1 answer
4
go_editor asked Jul 8, 2016
2,232 views
What is the size of the Unicode character in Windows Operating System?8-Bits16-Bits32-Bits64-Bits