Going further
Generic code with templates, reliable error handling and files, and the habits of modern C++.
About 8 hours of study
Learning objectives
- Write function and class templates
- Throw and catch exceptions
- Read and write files
- Apply RAII and modern features
Lessons
- 1
Templates Intermediate
Write one function or class that works for many types, and see how the compiler generates the code for each.
- 2
Exceptions and files Intermediate
Report and handle errors with throw, try and catch, and read and write files with streams that close themselves.
- 3
Modern C++ Intermediate
The habits of current C++: auto and range-based for, enum class, objects that clean up after themselves, smart pointers and lambdas.
Module practice
- C++: The largest of a listEasy
- C++: A two-value boxMedium
- C++: A queue templateHard
- C++: Safe conversionEasy
- C++: Save and loadMedium
- C++: An account with its own errorsHard
- C++: enum classEasy
- C++: Objects that clean upMedium
- C++: Tracking ordersHard