A try block can be nested and propagated to an external capture when the try inner module is caught in an exception. When an inner layer has caught an exception, it is no longer propagated to the outer layers. When you need to propagate to the outer layer, you need to catch the exception internally and then throw the exception again, and you can propagate to the outside. Note that the copy constructor is called when the exception is re-thrown.
When the exception is not captured, the Terminate function is called, and the Terminate function terminates the process by calling the system's abort () function by default. You can use the Set_terminate function to set the function called by terminate.
The stack unwind is defined by looking up along the nested call link until a catch clause is found for the exception. This process is called stack unwinding. During stack unwinding, destructors are called for production local objects.
An exception can be thrown in the constructor, and the constructed object should be eliminated if an exception is thrown (if you have constructed an obj = new obj, make sure to delete the new object). The destructor is not called because the construct is not completed.
Note: When an exception is thrown, the destructor is called instead of catching the exception, and after the exception is thrown in main, the Terminate function is called when the destructor is called before the exception is caught and an exception is thrown. It makes no sense to throw an exception, so generally you should not throw an exception in a destructor.
C + + exception handling (use of Try statements, exception propagation, stack expansion)