In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "what is the exception handling when the C++ program is running". In the daily operation, I believe many people have doubts about the exception handling when the C++ program is running. The editor consulted all kinds of data and sorted out the simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts about "what is the exception handling when the C++ program is running?" Next, please follow the editor to study!
The process of handling exceptions in C++ is like this: if an exception occurs in the executing program, it can not be handled in this function, but an error message is thrown and passed to the function at a higher level to solve the problem, which cannot be solved by the function at a higher level, and then passed to the next level at which it is handled. If you can't handle the upload step by step, the running system will automatically call the system function terminate, which will call abort to terminate the program. Such an exception handling method separates the exception throwing and handling mechanisms, rather than handling them in the same function. This makes the underlying function only need to solve the actual task, without thinking too much about the exception handling, and leave the exception handling task to the upper-level function to handle.
C++ 's exception handling mechanism consists of three parts: try (check), throw (throw), and catch (capture). Put the statements that need to be checked in the try module, check that the statement has an error, throw throws an exception and sends out an error message. Catch captures the exception information and handles it. Generally, the exception thrown by throw matches the type of exception caught by catch. The general format of exception handling is:
Try {checked statement throw exception} catch (exception type 1) {exception handling statement 1} catch (exception type 2) {exception handling statement 2}.
Let's demonstrate exception handling with an example:
# include "stdafx.h" # include template T Div (T XMago Ty) {if (yearly recall 0) throwy;// throws an exception returnx/y;} intmain () {intx=5,y=0; doublex1=5.5,y1=0.0; try {/ / checked statement std::cout
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.