About exceptions in c++?
给我你的怀抱
给我你的怀抱 2017-06-30 09:57:21
0
3
1051
  1. Is there any essential difference between the exceptions generated by normal debugging (as shown in the picture) and the try throw exceptions that are artificially trying to judge whether the user input is correct? Or does the exception mechanism when talking about C include the former? Or does it simply refer to the latter?

What is the first exception mentioned above judged by? For example, the accedd violation in the picture, is it judged by the compiler or other tools of the IDE?

给我你的怀抱
给我你的怀抱

reply all (3)
phpcn_u1582

@Evian What you said makes sense, let me make a supplement

  • Exceptions in c++ can only catch exceptions thrown by c++. To put it simply, it can only catch exceptions thrown by itself (not limited to the code you write, but also the runtime library).

  • In fact, the exception thrown by C++ is not a real exception, because it is just defined and predictable. The real exception is only triggered by the CPU after execution, that is, the exception thrown by the hardware.

  • The hardware will not directly care about c++, it will be left to the operating system to handle it. Given the different operating systems, exception handling is also inconsistent - but they are not handed over to the upper level language.

  • Take the relatively complete Windows exception handling as an example, it will

  1. Leave it to the debugger (the process must be debugged)

  2. Execute VEH

  3. Execute SEH

  4. TopLevelEH (the process will not be executed when it is debugged)

  5. Leave it to the debugger (the exception handling above said it couldn’t be handled, so I handed it to the debugger again)

  6. Call exception port notification csrss.exe

    曾经蜡笔没有小新

    Memory read violations are determined by the hardware and then handed over to the operating system for processing. (I don’t know much about C++, but this is not like a C++ exception, but an exception thrown by Windows.)

      刘奇

      I didn’t get your point. Some libraries have built-in exception classes, or you can customize exception classes. In the end, they all inherit fromstd::exception. There is essentially no difference. Also, this is a runtime exception and has nothing to do with the compiler or IDE.

        Latest Downloads
        More>
        Web Effects
        Website Source Code
        Website Materials
        Front End Template
        About us Disclaimer Sitemap
        php.cn:Public welfare online PHP training,Help PHP learners grow quickly!