


















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















Object-Oriented Programming (OOP) Lecture No. 44
class DivideByZero { public: DivideByZero() { } }; int Quotient(int a, int b){ if(b == 0){ throw DivideByZero(); } return a / b; }
function2()
main()
function1()
function2() main()
main()
int Quotient(int a, int b) {
if(b == 0){ throw DivideByZero(a); } return a / b;
}
for ( int i = 0; i < 10; i++ ) { try { GetNumbers(a, b); quot = Quotient(a, b); ... } catch(DivideByZero & obj) { obj.Print(); i--; } } cout << “\nSum of ten quotients is ” << sum;
try{ ... } catch(DivideByZero){ ... } catch(IntergerOutOfRange){ ... } catch (InputStreamError){ }
try{
...
}
catch (MathError){
}
catch (InputStreamError){
}