I decided to read about exceptions finally and the very first example isn't running as expected.
I'm using VC++. This didn't work on dev-c++ either.
Here's the code:
Here's whats in the included header
int main(int argc, char *argv)
int top = 90;
int bottom = 0;
cout <<"top /2 = " << (top / 2) << endl;
cout <<"top divided by bottom =";
cout <<(top / bottom)<<endl;
cout <<"top / 3 = " <<(top/3) <<endl;
cout << "An exception has been thrown." <<endl;
cout <<"Done." <<endl;
Here's what happens.
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <stdio.h> //unrelated:why is this needed?
#include <tchar.h> //unrelated:why is this needed?
It compiles without a complaint but when I run it without debugging instead of the exception being handled by the catch block, windows send error report appears and none of the code following the catch block gets executed. If I run it with debugging it tells me that there is an unhandled exception of (expectedly) integer divide by zero. shouldn't the catch(...) be handling that exception instead of the program crashing?