Skip to main content

Checkpoint: Object-Oriented Design

intermediate30 min readLesson 79 of 204

One type combining encapsulated state, a shared static counter, and a const-correct read-only surface.

This checkpoint asks for one small type that gets four things right at once:

  1. Encapsulation — the vector of titles is private; operations are the only door.
  2. Instance vs class state — each Library has its own titles; total_copies() is shared.
  3. Const correctnesssize()/has() work through a const Library&.
  4. Pass-by-moveadd(std::string title) takes by value and moves in (one parameter serves both lvalues and rvalues).

Aim for the shortest implementation that satisfies all four tests.