When should a function throw an exception?

Answer

A function should throw an exception when it is not able to fulfil its promise.

As soon as the function detects a problem that prevents it from fulfilling its promise, it should throw an exception. If the function is able to handle the problem, recover itself and deliver the promise, the exception should not be thrown.

If an event happens very frequently then exception handling is not the best way to deal with it. It requires proper fixation.

All cpp Questions

Ask your interview questions on cpp

Write Your comment or Questions if you want the answers on cpp from cpp Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---