Sponsered Links
Categories
Sponsered Links

multiple catch statements in C++ exception

 

This is a multiple catch statements in C++ exception example, In this example we are going to learn how to use multiple catch statement.

#include <iostream> 

void fun(int test)
  try
    if(test
       throw test;           
    else 
       throw "Value is zero";
  
  catch(int i) { 
    cout << "Caught First  Example: " << i << '\n'
  
  catch(char *str) { 
    cout << "Caught a string: "
    cout << str << '\n'
  

 
int main()
  cout << "start\n"
 
  fun(1)
  fun(2)
  fun(0)
  fun(3)
 
  cout << "end"
 
  return 0
}


 
 
Sponsered Links
Latest Updates
 
All Content of this site is for learning only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright © 2009 JSPSERVLETTUTORIAL.INFO All Right Reserved