Going further

Generic code with templates, reliable error handling and files, and the habits of modern C++.

About 8 hours of study

Learning objectives

Lessons

  1. 1

    Templates Intermediate

    Write one function or class that works for many types, and see how the compiler generates the code for each.

  2. 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. 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

Module quiz

1. What does the compiler do with a template?
2. Why put a specific catch before a general one?
3. What closes a file stream in normal use?
4. How does enum class differ from a plain enum?
5. What should own a heap object in modern C++?

‹ Your own types and the standard libraryFinal assessment ›