C++ Try Catch Block

Objectives :

  • This example is similar to myException1.htm
  • Here the user are allowed to enter zero values and the divide by zero error is caught in a function with throw keyword and with a custom number for like 404
  • Code: myException2.txt

Step: 1 Create a project myException2

Step: 2 Create a source file

Step: 3 Edit Source code

Step: 4 Runtime View

a) testing for the error "divide by zero"

Note the error number

Enter the letter will abort the runtime phase of the application. (FYI, the red square in the above image won't be there when you abort an application.0

 

Rolling back to entry point

Step: 5b