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

Why is c++ called oops?

851


Can a constructor return a value?

944


What is general format for a prototype?

840


What is the use of cmath in c++?

833


List the types of polymorphism in c++?

876


What is singleton class in c++?

827


Write a code/algo to find the frequency of each element in an array?

874


Is java a c++?

801


Specify different types of decision control statements?

625


Explain the different access specifiers for the class member in c++.

778


What are its advantages and disadvantages of multiple inheritances (virtual inheritance)?

913


What data encapsulation is in c++?

815


When you overload member functions, in what ways must they differ?

833


What are the 3 levels of programming languages?

824


Write a single instruction that will store an EVEN random integer between 54 and 212 inclusive in the variable myran. (NOTE only generate EVEN random numbers)

1742