Exception Handling: 1) Handling Mechanism: Try {if any function in the try clause throws logic_error or calls another code function to throw such exceptions, the catch statement will be executed immediately ;} catch (logic_error & e) {the keyword throw indicates that the function will exit immediately and will not return to the calling handler program. Instead, it will exit until the exception-handling statement is found ;} n if an exception exists, create an exception object through the throw operation and throw it. N if no exception occurs during Protection Segment execution, the catch clause following the try block will not be executed. The program continues to execute the statements following the last catch clause following the try block. N catch clauses are checked in the order they appear after the try block. The matched catch clause will capture and handle exceptions (or continue throwing exceptions ). N if the matching processor is not found, the terminate function is automatically called. The default function is to call the abort termination program. 2) Throw and capture value: exception capture mechanism: you do not need to capture all exceptions in the Try block. When an exception occurs, the exception handling mechanism searches for matched handlers from the inside out, and only the first processing program that meets the conditions is executed. When writing a catch statement, you should first match the derived class and then the base class. The thrown value can be of any type, basic type or object. However, there is a type conversion problem during capture, (int-> double, or char * à string) change the original intention. To solve this problem, it throws and captures the object: Example: # include <iostream >#include <stdexcept> usingnamespace std; classFutureValueError: public logic_error {public: FutureValueError (stringe): logic_error (e) {}}; doublefuture () {throw FutureValueError ("illegalfuture_value"); return 2.0;} voidread () {try {double d = future (); cout <"intre Ad () "<endl; // in this case, Future statements will never be executed} catch (bad_alloc & e) {cout <" catch bad_allocerror "<e. what () <endl ;}}voidprocess_record () {try {read ();} catch (logic_error & e) {cout <"catchlogic_error" <e. what () <endl ;}} intmain () {process_record (); system ("pause") ;}running result: Analysis: There is no catch statement because FutureVauleError is thrown; therefore, the catch statement in the read () statement does not meet the conditions in the catch statement that is thrown to the read () function block. Therefore, the catch statement in the read () statement continues to be thrown to process_error, find the corresponding processing mechanism. The statements after the function is thrown cannot be executed. The root class of the exception level in the standard library exception Handling ++ standard library is called exception, the interface defining the exception class in the header file <exception> of the library is as follows: namespacestd {class exception {public: exception () throw (); exception (const exception &) throw (); exception & operator = (const exception &) throw (); virtual ~ Exception () throw (); virtual const char * what () const throw ();};}