C++ Tutorials | L64: Stack Unwinding In C++ | Exception Handling | Try Catch | The Easy Concepts

142 Просмотры
Издатель
C++ Tutorials | L64: Stack Unwinding In C++ Exception Handling | Exception Handling | Try Catch Throw Keywords in C++ The Easy Concepts

In this tutorial, we have discussed the concept of stack unwinding. The process of removing function entries from the function call stack at run time is called Stack Unwinding. Stack Unwinding is generally related to Exception Handling. In C++, when an exception occurs, the function call stack is linearly searched for the exception handler, and all the entries before the function with exception handler are removed from the function call stack. So exception handling involves Stack Unwinding if an exception is not handled in the same function (where it is thrown).

Rethrowing an expression from within an exception handler can be done by calling throw, by itself, with no exception. This causes the current exception to be passed on to an outer try/catch sequence. An exception can only be rethrown from within a catch block. When an exception is rethrown, it is propagated outward to the next catch block.

Exceptions are run-time anomalies or abnormal conditions that a program encounters during its execution.
C++ provides the following specialized keywords for this purpose.
try: represents a block of code that can throw an exception.
catch: represents a block of code that is executed when a particular exception is thrown.
throw: Used to throw an exception. Also used to list the exceptions that a function throws, but doesn’t handle itself.

Please watch the full video to learn the concepts in more detail.

Learn Computer Science Concepts in an Easy Way !!

Website - http://www.theeasyconcepts.com/
Facebook - https://www.facebook.com/theeasyconcepts/
Twitter - https://twitter.com/theeasyconcepts
GitHub - https://github.com/deepakuniyaliit/OOP
LinkedIn - https://www.linkedin.com/in/deepak-uniyal-592b7545/
Telegram - https://t.me/theeasyconcepts
Категория
Язык программирования C++
Комментариев нет.