So, I'm using Xcode 3.1.1 and I've bee learning C++ for awhile now. Anyways, I'm on one of the last chapters, and it deals with exceptions.
Everything seems to be going fine, but then, I run the code, and it throws an operating system exception telling me
Well, thanks, that's the exact same behavior the program showed without try/catch blocks. So, I set breakpoints and step through it. And it gets to the line where the program divides by zero, throws an operating system exception, and puts me back on the line. It's behaving as if the try/catch block don't exist. This is really strange. Does anyone know what's going on?
Code:
#include <iostream>
using namespace std;
const int DefaultSize = 10;
int main()
{
int top = 90;
int bottom = 0;
try
{
cout << "top / 2 = " << (top/ 2) << endl;
cout << "top divided by bottom = ";
cout << (top / bottom) << endl;
cout << "top / 3 = " << (top/ 3) << endl;
}
catch(...)
{
cout << "something has gone wrong!" << endl;
}
cout << "Done." << endl;
return 0;
}
Everything seems to be going fine, but then, I run the code, and it throws an operating system exception telling me
Code:
Program received signal: EXC_ARITHMETIC.