11.x — Chapter 11 summary and where to go next

📘 Chapter 11⏱ about 2 min read✍️ Beginner friendly
Read one box at a time. No rush.

Quick review#

  • Templates let one piece of code work with many types.
  • <algorithm> has ready-made tools: sort, find, count, and more. Lambdas are tiny on-the-spot functions.
  • Inheritance builds a class on top of another. virtual + override let each child behave its own way.
  • throw, try and catch handle errors.
  • std::ifstream and std::ofstream read and write files.
Quick check

Pick an answer. You find out right away if it is right.

Quick check #1

What does template <typename T> let you do?

Quick check #2

What does std::sort(v.begin(), v.end()) do?

Quick check #3

Where does code go that might throw an exception?

Quiz time
Question #1

Write a template function swapIfBigger(T& a, T& b) that swaps a and b only if a is bigger than b.

C++
template <typename T>void swapIfBigger(T& a, T& b){    if (a > b)        std::swap(a, b);}
Question #2

Sort a std::vector<std::string> by length, shortest first, using std::sort and a lambda.

C++
std::sort(words.begin(), words.end(),    [](const std::string& a, const std::string& b) { return a.length() < b.length(); });

What next?#

You now know the core of C++. Here are good next steps:

  • Build something! A text adventure, a to-do list saved to a file, a quiz game, a tiny bank system.
  • Carry on to chapter 12 for power tools and two full projects.
  • Re-read the chapters that felt hard. They'll make more sense now.
  • Keep the cheat sheet open while you code.
  • Try a graphics library like SFML or raylib to make simple games.
Key idea

Nobody learns programming by reading alone. Pick a small project and write it, one box at a time. You've got this! 🚀

Finished reading? Tick it off. Your progress is saved in this browser.

Tip: press ← / → to move between lessons, / to search.