#include using namespace std; template T MyDiv(T a, T b) { if (b == 0) { throw 0; } cout << "Dividing " << a << " by " << b << "." << endl; return a/b; } int main() { cout << MyDiv(1,2) << endl; cout << MyDiv(2,1) << endl; cout << MyDiv(2.2, 1.1) << endl; cout << endl; try { cout << "I'm gonna divide by zero carefully " << endl; cout << MyDiv(2,0); cout << "Did that work?" << endl; } catch (...) { cout << "Caught a throw from somewhere " << endl; } cout << endl; cout << "Now an unwrapped divide " << endl; cout << MyDiv(2,0); cout << "All done with the exercise " << endl; return 0; }