1.

How to handle the exception in constructor?(a) We have to throw an exception(b) We have to return the exception(c) We have to throw an exception & return the exception(d) We have to catch an exceptionThe question was asked during an online exam.The question is from Catching Exceptions topic in division Derived Classes, Templates & Exception Handling in C++ of C++

Answer»

Right option is (a) We have to THROW an EXCEPTION

For explanation: As a constructor don’t have a RETURN type, We have to throw the exception.



Discussion

No Comment Found

Related InterviewSolutions