[CPP] Exceptions and Lambdas
How do we report errors? Return an error value from function set a global error code Throw an exception Exceptions Exceptions are “thrown” to report exceptional circumstances You can throw any type of object, fundamental type or pointer as an exception in C++ The standard class library provides some standard exception types, all derived from exception class You add handler code to catch the exception The stack frame is unwound, one function at a time (as if the functions returned immediately) until a catch which matches the type throw is found Catching exceptions First specify that you want to check for exceptions(try) Then call the code which may raise the exceptions Then specify which exceptions you will catch, and what to do The same as Java The catch clause A catch clause will match an exception of the specified type catch clauses are checked in the order in which they are encountered, the order of the catch clauses matters! Pointers and objects are ...