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
What are associate containers?
Is c or c++ more useful?
How the keyword struct is different from the keyword class in c++?
How one would use switch in a program?
What is the difference between mutex and binary semaphore?
What is atoi in c++?
What is protected inheritance?
why is c++ called oops? Explain
What are maps in c++?
Can I make ios apps with c++?
Can we declare a base-class destructor as virtual?
What are namespaces in c++?
What is microsoft c++ redistributable 2013?
What does new return if there is insufficient memory to make your new object?
What are static member functions?