In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
What is the concept of C++ exception? for this question, this article introduces the corresponding analysis and answer in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible way.
When using the programming language to develop the program, we all need to handle the exception in order to make our program perfect. In the C++ language, there are also operations about exception handling. Here we will introduce several common operation methods of C++ exceptions, hoping to bring some help to you.
The keyword throw (something) restriction is added after the C++ function to limit the abnormal security of this function.
Void f () throw () means that f does not allow any exceptions to be thrown, that is, f is exception safe.
Void f () throw (...) Indicates that f can throw any form of exception.
Void f () throw (exceptionType); means that f can only throw C++ exceptions of type exceptionType.
Quote a joke from others:
Throw () would probably say, "Oh, whatever you throw, don't throw it." no, no, no.
Throw (...) He smiled and said kindly, "throw it, throw it as much as you want." no, no, no. no, no, no. "
Throw (type) was anxious: "I can't do that. I can only throw my cigarette butts, otherwise it would be too bad to throw away my ancestral gold ring."
There are three ways to pass exceptions on C++:
1. Pass value (by value)
In the process of passing values, there will be a copy of temporary objects, which can not solve the problem of polymorphism, as follows: myexception inherits exception, but can not be correctly called the method of myexception, resulting in the cutting of abnormal objects.
Class myexception:public exception {public: virtual const char* what () throw (); const char* myexception::what () {return "myException";} class A {public: a () {} void f () throw () {throw myexception ();}}; int main () {An a; try {a.f ();} catch (exception exc) {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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.