Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

cpp custom exception

int main()
{
   int err = -99;
   cout << "Before try 
";
   try {
      cout << "Inside try 
";
      if (err < 0)
      {
         throw err;
         cout << "After throw (Never executed) 
";
      }
   }
   catch (int err ) {
      cout << "Exception Occured! 
";
   }
 
   cout << "After catch (Will be executed) 
";
   return 0;
}
 
PREVIOUS NEXT
Tagged: #cpp #custom #exception
ADD COMMENT
Topic
Name
2+5 =