Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

c++ exeption handling

#include <iostream>
using namespace std;
 
int main()
{
   int x = -1;
 
   // Some code
   cout << "Before try 
";
   try {
      cout << "Inside try 
";
      if (x < 0)
      {
         throw x;
         cout << "After throw (Never executed) 
";
      }
   }
   catch (int x ) {
      cout << "Exception Caught 
";
   }
 
   cout << "After catch (Will be executed) 
";
   return 0;
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #exeption #handling
ADD COMMENT
Topic
Name
6+4 =