#include <iostream>
#include <string>
#include <exception>

using namespace std;

//const int DivideByZero = 1;
//const int DivideZero = 2;

class DivideByZero : public runtime_error {
public:
	DivideByZero() : runtime_error("Divide by zero") {}
};

class DivideZero : public exception {
public:
	DivideZero() {}
	const char* what() const throw() {
		return "Divide zero";
	}
};


int main() {
	int a, b;
	cout << "Enter a: "; cin >> a;
	cout << "Enter b: "; cin >> b;
	try {
		if( !b ) 
			throw DivideByZero();
		if( !a )
			throw DivideZero();
		else
			cout << a/b;

	} catch (exception e) {
		cout << "catch by exception:" << e.what() << endl;
	} catch (DivideByZero &e) {
			cout << e.what() << endl;
	} catch (DivideZero &e) {
			cout << e.what() << endl;
	} catch (...) {
		cout << "Unkown error thrown" << endl;
	}

	system("pause");
}