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 ?||5 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
the destructors of all the member objects that were
correctly created are called, then code goes to the catch
statement if any
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
|Is This Answer Correct ?||2 Yes||2 No|
Can a list of string be stored within a two dimensional array?
What is object file? How can you access object file?
Write a program which uses Command Line Arguments
plz send me National informatics center paper pattern
What will strcmp("Astring", "Astring"); return a) A positive value b) A negative value c) Zero
Can recursive program be written in C++?
There is a magic square matrix in such a way that sum of a column or a row are same like 3 5 2 4 3 3 3 2 5 sum of each column and row is 10. you have to check that matrix is magic matrix or not?
Under what conditions is multiple inheritance not recommended?
What is meant by entry controlled loop? What all C++ loops are exit controlled?
What are pointer-to-members? Explain.
is throwing exception from a constructor not a good practice ?
How can you quickly find the number of elements stored in a a) static array b) dynamic array ?