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

What is a null object in c++?

854


Define pure virtual function?

758


What is enum c++?

890


How long it will take to learn c++?

817


What is the protected keyword used for?

863


Does there exist any way to make the command line arguments available to other functions without passing them as arguments to the function?

1004


Explain the operation of overloading of an assignment operator.

914


Write a corrected statement in c++ so that the statement will work properly. if (4 < x < 11) y=2*x;

1748


Is c++ harder than java?

812


What is rvalue?

915


Is c better than c++?

849


You want to link a c++ program to c functions. How would you do it?

747


Why are arrays usually processed with for loop?

992


If you don’t declare a return value, what type of return value is assumed?

748


What are c++ tokens?

812