// Source: "Software Design ...", John A Robinson, Newnes, 2004, page 162. #include using namespace std; int main() { typedef double numtype; numtype a(0); numtype b(1); try { numtype c = b/a; cout << "c = " << c << endl; } catch(...) { cout << "Division by zero was exceptional!\n"; } try { numtype d = a/a; cout << "d = " << d << endl; } catch(...) { cout << "Dividing zero by zero was exceptional!\n"; } }