// AhmedWafaa Typing


#include <iostream>
#include <exception>

using namespace std;

void errordetecting() {
  
  bool error1 = true;
  bool error2 = false;
  
   if(error1){
   	throw bad_alloc();
   }
   	
   if(error2){
   	throw exception();
   }
}

    int main() {
	
     try {
     	
     errordetecting();
     
	 }
	 catch(bad_alloc &e) {
	 	
	 	cout << "this is exception " << e.what() << endl;
	 }
	 catch( exception &e) {
	 	
	 	cout << "this is bad_alloc " << e.what() << endl;
	 }
	
	return 0;
}

Leave a comment

Your email address will not be published. Required fields are marked *