is throwing exception from a constructor not a good practice ?

Answer Posted / vikas sood

throwing exception from a constructor is not bad at all. It
is actually advised to use exceptions when you fail to
create your object properly due to any reason. In this case
memory will not be allocated for the object and no
destructor will be called.

Is This Answer Correct ?    11 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Write a program to find the Fibonacci series recursively.

708


Why is it necessary to use a reference in the argument to the copy constructor?

717


Define copy constructor.

708


What are the advantages of pointers?

682


Define friend function.

655






What is the use of class in c++?

663


Is java a c++?

652


what are the decision making statements in C++? Explain if statement with an example?

749


Where the memory to the static variables is allocated?

645


What are put and get pointers?

697


Write about the stack unwinding?

729


Explain the concept of memory leak?

746


What is the difference between a definition and a declaration?

661


How do we balance an AVL Tree in C++?

731


Will a catch statement catch a derived exception if it is looking for the base class?

635