With the following code, I get the "Gotcha!" with python.
try: x = 0 y = 3/x except Exception: # ZeroDivisionError print "Gotcha!"
I think this is the equivalent C++ code, but it can't catch the exeption.
#include <iostream>
int main()
{
int x = 0;
//float y = 3.0/x;
int z = 0;
try {
z = 3 / x;
} catch (std::exception) {
std::cout << "Gotcha!";
}
std::cout << z;
}
Floating point exception
What went wrong? How can I catch this exception?