In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 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.
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.