What happens if an exception is throws from an, object's
constructor and object's destructor?

Answer Posted / som shekhar

When an exception is thrown from the object constructor,
then the destructor of the object wont be called. But to
undone all the things that happened in the c'tor before the
exception is thrown, you can make use of smart
pointer(either boost smart pointer or std auto pointer).

when an exception is thrown from the destructor the compiler
terminates the application.

So it is advisable not to throw an exception in the
destructor , better to do "something else".

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the default access level?

625


Is C++ case sensitive a) False b) Depends on implementation c) True

616


Are there interfaces in c++?

558


What do you mean by translation unit?

606


What is an undefined behavior and sequence points

568






Write about the stack unwinding?

630


Explain the extern storage classes in c++.

556


Write a program which is required to process the time of a clock in hours and minutes, entered from the keyboard. With this program, there are two requirements for any data entered by a user: 1. The data must be of the correct type (in this case, two ints). 2. The data must be in the correct range: this means that, for the minutes, negative numbers and any number above 59 must be rejected; for the hours, negative numbers and any number above 23 must be rejected. Output error message for invalid data input. Output the time one and a half hour after the time input. i.e. Hour: 22 Min: 32 One and a half hour after 22:32 is 00:02

1514


What do you know about near, far and huge pointer?

603


write a program that withdrawals,deposits,balance check,shows mini statement. (using functions,pointers and arrays)

1804


Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

565


Differentiate between late binding and early binding. What are the advantages of early binding?

586


What is function overriding in c++?

606


What are c++ redistributables?

564


What is #include c++?

571