EECS 280 Lecture Notes - Lecture 22: Null Pointer, Interrupt, Error Detection And Correction

67 views1 pages

Document Summary

We"re only going to be talking about exceptions in c++ We want to nd a way to detect errors at runtime. We will use exceptions to separate error detection and error corrections into two parts of the program. Let"s say, for example, that we have a problem: in our factorial function, we can"t have an input that it"s a negative number. Instead of having a requires clause, we could look at it in a different way, and do runtime checking. There are three general strategies: solve the problem. Try to x things by modifying code or returning default outputs (i. e. return 1): crash the program. Use abort() or exit(): pass the problem to someone else. C++ exceptions let us detect an error in one part of the program and correct it in a different part of the program. We could detect an error in factorial() but correct it in main(). Throw the error, and someone else can catch it.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents