Exceptions and design
Reporting errors with exceptions and cleaning up during stack unwinding, then putting the whole course together in the design of a complete small program.
About 7 hours of study
Learning objectives
- Throw and catch exceptions
- Order catch blocks correctly
- Explain stack unwinding and RAII
- Design classes, ownership and error handling for a small system
Lessons
- 1
Exceptions
throw reports an error, try and catch handle it far away, and destructors still run on the way: safe error handling in C++.
- 2
Project: a small library system
Putting it together: classes with private data, inheritance and virtual functions, a vector of pointers, and exceptions for errors.
Module practice
- C++: Catch a bad indexEasy
- C++: Division with exceptionsMedium
- C++: Your own exception classesHard
- C++: Loan periods for each kind of itemEasy
- C++: A library that lends and takes backMedium
- C++: Late fines in the libraryHard