What happens if an exception is throws from an, object's
constructor and object's destructor?
Answers were Sorted based on User's Feedback
Answer / dee
if the exception is thrown in constructor, its caught or
function terminate will eb called.
U cannot throw exception from destructor
| Is This Answer Correct ? | 6 Yes | 2 No |
Answer / 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 |
Answer / akshay
constructor:
the destructors of all the member objects that were
correctly created are called, then code goes to the catch
statement if any
dtors:
legally allowed, however, it should be caught within the
function. if it is not caught, then it may lead to a call to
terminate() function. this call would happen in the case
when the destructor was itself called due to stack unwinding
happening because of another exception in probably some
other function.
| Is This Answer Correct ? | 2 Yes | 2 No |
What is the maximum value of a unsigned char a) 255 b) 256 c) 128
give me some class & objects examples?
Do you know the use of vtable?
What is the difference between global int and static int declaration?
Explain what is class definition in c++ ?
write a program that will produce the ff. output. "what fruit will you buy? 1)apple 2)orange 3)mango ENTER CHOICE (1,2 or 3)> HOW MANY WILL YOU BUY?> THAT WILL COST XX.XX
Specify different types of decision control statements?
What is the best sorting algorithm, when there is a large amount of data, that cannot be fit in the main memory. ?
What is the use of the this pointer?
What is c++ mutable?
what is Loop function? What are different types of Loops?
difference between c and c++?
38 Answers Cognizant, IBM, Infosys, Oracle, Sarva Shiksha Abhiyan, Wipro,