- "" ++, - " ", glibc Linux, , -, Cygwin .
try/catch throw.
int main() {
try
{
const double input = -1;
double result = square_root(input);
printf("Square root of %f is %f\n", input, result);
return 0;
}
catch(...)
{
printf("Caught exception in main that wasn't handled...");
return 10;
}
}
, , - " " - :
int actual_main() {
const double input = -1;
double result = square_root(input);
printf("Square root of %f is %f\n", input, result);
return 0;
}
int main()
{
try
{
return actual_main();
}
catch(std::exception e)
{
printf("Caught unhandled std:exception in main: %s\n", e.what().c_str());
}
catch(...)
{
printf("Caught unhandled and unknown exception in main...\n");
}
return 10;
}
, , , "" - , , , Cygwin .