C++ Exception TryCatch1

Objectives :

  • In C++ try and catch block is bit different than C# and Java programming languages.
  • Comparison (==) operator
  • goto keyword
  • exit(1) function to quit an application before completion.
  • Code: myException1.txt

Step: 1 Create a project

Step: 2 Create a source file

Step: 3 Edit Source code

Step: 4 Runtime Views

a) checking values under 10 should throw an exception

b) additional checking on goto reference and compare operator.

Note cursor was set back to an anchor "here:" or there for the first and second values respectively.

c) Choosing y or n will set the cursor to run one more time or exit respectively.

Choosing "n" will exit the application. Note code exits before the line "

Compare, here with two other instances  where we entered "" or '' , the cursor will complete after printing the last line " No Final....". In the above illustration the application aborts with exit(1) function.


Step: 5b