Monday, 11 September 2017

Exceptions Handling in C++



-If there is no catch statement for a try statement, then program ll not crash but will show abnormal behavior.

-try{
throw derived
}
catch(base){}
catch{derived}

The program will go in the base segment as it is written before derived statement.

-If you've one if/else block instead of one try/catch block, and if an exception throws in the try/catch block, then the if/else block is faster (if/else block: around 0.0012 milliseconds, try/catch block: around 0.6664 milliseconds). If no exception is thrown with a try/catch block, then a try/catch block is faster. But if you use 100 try/catch blocks in your program, and if one exception throws, then 100, if/else blocks, is faster.

No comments:

Post a Comment