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:
- Encapsulation — the vector of titles is private; operations are the only door.
- Instance vs class state — each
Libraryhas its own titles;total_copies()is shared. - Const correctness —
size()/has()work through aconst Library&. - Pass-by-move —
add(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.