explaingit

mooophy/cpp-primer

8,297C++Audience · developerComplexity · 1/5LicenseSetup · moderate

TLDR

A complete set of worked exercise solutions for the C++ Primer textbook (5th edition), organized chapter by chapter across all 19 chapters, covering modern C++11 and C++14 with compilable source files.

Mindmap

mindmap
  root((cpp-primer))
    Content
      Chapter solutions
      19 chapters
      C++11 and C++14
    Topics covered
      Variables and classes
      Standard library
      Templates
      Advanced features
    How to use
      Compare solutions
      Compile and run
      Study reference
    Compilers
      Visual Studio
      GCC
      Clang
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Check your answer to a C++ Primer exercise against a reference implementation when you get stuck.

USE CASE 2

Study how C++11 and C++14 features like lambdas, move semantics, and templates are used correctly in practice.

USE CASE 3

Compile and run individual exercise solutions to see the expected output and understand the intended behavior.

Tech stack

C++

Getting it running

Difficulty · moderate Time to first run · 30min

Each file must be compiled with C++14 support: use -std=c++14 on Linux or -std=c++1y on macOS.

Released into the public domain under CC0, use for any purpose with no restrictions whatsoever.

In plain English

This repository is a collection of worked answers to the exercises in C++ Primer, 5th Edition, a widely used textbook for learning the C++ programming language. The solutions cover the modern C++11 and C++14 standards that the book's 5th edition introduced. The repository is organized to match the book's chapter structure. It runs from Chapter 1 (Getting Started) through all four major parts of the book: the basics of variables, strings, functions, and classes, the standard C++ library including containers and algorithms, tools for building reusable classes, and advanced topics such as templates and specialized library features. In total, answers are available across all 19 chapters. Each exercise solution is stored as a C++ source file you can compile and run yourself. The README lists the compilers the author recommends: Visual Studio 2015 or later on Windows, g++ 5.0 or later on Linux, and Clang 3.7 or later on macOS. Each file needs to be compiled with a C++14 flag, such as -std=c++14 on Linux or -std=c++1y on macOS. The repository is licensed under CC0, which means the code has been placed in the public domain and you can use it for any purpose without restriction. If you are working through C++ Primer and get stuck on an exercise, this is a reference to compare your approach against. The solutions were contributed over time by the repository owner and others, and some chapters may have fuller coverage than others. There is also a linked Chinese-language discussion group for readers who prefer that.

Copy-paste prompts

Prompt 1
I'm stuck on C++ Primer Chapter 12, exercise 12.14. Show me a solution using shared_ptr that correctly manages a StrBlob dynamic array.
Prompt 2
In the cpp-primer solutions, how is a Chapter 16 templates exercise structured? Explain how function template type deduction works in that example.
Prompt 3
I want to compile a solution from the cpp-primer repo on macOS with Clang. What flags do I need and how do I run it?
Prompt 4
Show me how the cpp-primer solutions handle Chapter 7 class exercises, specifically constructors, member functions, and access control.
Open on GitHub → Explain another repo

← mooophy on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.