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
Explain the concept of dynamic allocation of memory?
Is string an object in c++?
What are stacks? Give an example where they are useful.
Does c++ have arraylist?
What is array in c++ example?
Explain class invariant.
You run a shell on unix system. How would you tell which shell are you running?
what is a reference variable in C++?
Explain function overloading and operator overloading.
If a function doesn’t return a value, how do you declare the function?
What is an arraylist c++?
Why ctype h is used in c++?
How many ways can a variable be initialized into in C++?
What are the characteristics of friend functions?
Give example of a pure virtual function in c++?