throw an integer out : Throw « Language « C++






throw an integer out

  
#include <iostream>
using namespace std;

int main () {
  try
  {
    throw 20;
  }
  catch (int e)
  {
    cout << "An exception occurred. Exception Nr. " << e << endl;
  }
  return 0;
}
  
    
  








Related examples in the same category

1.Throw Int out when reading integer file
2.Throw Char Star
3.Throwing Two Types
4.Throwing Multiple Basic
5.Throwing Exceptions
6.throw different types of exceptions with if statement
7.Throwing Exceptions out of nested function calls
8.throw exception out of function
9.Restricting function throw types.Restricting function throw types.
10.Example of 'rethrowing' an exception.Example of 'rethrowing' an exception.
11.An exception can be thrown from outside the try blockAn exception can be thrown from outside the try block
12.Demonstrating stack unwinding.
13.Demonstration of rethrowing an exception.
14.checks for divide-by-zero and throw exception