Content deleted Content added
Line 500:
</syntaxhighlight>
It is also possible to raise exceptions purposefully, using the <syntaxhighlight lang="C++" inline>throw</syntaxhighlight> keyword; these exceptions are handled in the usual way. In some cases, exceptions cannot be used due to technical reasons. One such example is a critical component of an embedded system, where every operation must be guaranteed to complete within a specified amount of time. This cannot be determined with exceptions as no tools exist to determine the maximum time required for an exception to be handled.<ref>{{Cite book |title=The C++ Programming Language |last=Stroustrup |first=Bjarne |publisher=Addison Wesley |year=2013 |isbn=9780321563842 |pages=349}}</ref> Unlike languages like Java, C# and D, which only allows objects that extend <code>Throwable</code> (whose subclasses are <code>Error</code> and <code>Exception</code>), C++ allows anything, both primitive types and objects, to be thrown and caught. C++ does not have an Error class like those languages, but has an Exception class (<code>std::exception</code>). In the aforementioned languages, the distinction between Error and Exception is made in that Errors usually represent irrecoverable states, while Exceptions are more acceptable to catch and represent circumstances that are normal to occur throughout the execution of a program.
Unlike [[Signal handler|signal handling]], in which the handling function is called from the point of failure, exception handling exits the current scope before the catch block is entered, which may be located in the current function or any of the previous function calls currently on the stack.
|