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
Differences between private, protected and public and give examples.
Explain virtual destructor?
Mention the storage classes in c++.
What is the difference between struct and class?
Tell me difference between constant pointer and pointer to a constant.
If a base class declares a function to be virtual, and a derived class does not use the term virtual when overriding that class, is it still virtual when inherited by a third-generation class?
Write a Program for read a line from file from location N1 to N2 using command line arguments. Eg:exe 10 20 a.c
What is switch case in c++ syntax?
What is c++ hiding?
What is difference between n and endl in c++?
What do you mean by translation unit in c++?
Write a program which uses Command Line Arguments
What is the difference between public, private, and protected access?
List the special characteristics of constructor.
Do vectors start at 0?