How to learn more about C++ exception handling
This article shows you how to in-depth understanding of C++ exception handling, the content is concise and easy to understand, can definitely brighten your eyes, through the detailed introduction of this article, I hope you can get something.
Basic exception handling
Exception handling mechanism: suspend problem handling, not in the current function, but in his caller (get on the bus first, then make up the ticket)
What is an exception: anything can be thought of as an exception, and an error is just a kind of exception.
Once an exception is thrown, it is not handled. If an exception is thrown, the default abort function is called to terminate the program.
Catch and handle exceptions:
Throw throws an exception: (the value is of any type, but it's just a reference for us to handle the exception, similar to the return value.)
Try (check, catch) and catch (handle exceptions): must appear together, and their parentheses {} cannot be omitted
Tip: anything can be thought of as an exception, and an error is just one of the exceptions-there is a situation that does not make the program work properly
How to throw an exception / / find the remainder of an and b how to throw an exception int division (int aline int b) {if (bounded in0) throw 0; / / throw a value (arbitrary)-- > and then deal with return a cout b;} void print (int a line int b) {cout