Skip to content

Guide · Open source

How to use C-Plus-Plus: clone, build and study the algorithms

Updated · written with AI from the project's own documentation and checked against our catalogue data

C-Plus-Plus is TheAlgorithms' open-source repository of algorithm implementations written in C++, covering computer science, mathematics, statistics, data science, machine learning and engineering. It is built for educators and students who want to study how algorithms work. This guide shows you how to get the code, what you need to compile it, and how to use the documentation to learn from it.

The Algorithms - C++TheAlgorithms/C-Plus-Plus · ★ 34.8k · MIT

Quick start

  1. 1Check your compiler. Confirm you have a C++17-capable compiler installed.
  2. 2Clone the repository. Run git clone https://github.com/TheAlgorithms/C-Plus-Plus to download the code.
  3. 3Open the documentation. Visit https://thealgorithms.github.io/C-Plus-Plus to browse explanations alongside the source.
  4. 4Pick a topic. Choose an algorithm area such as mathematics, machine learning or computer science.
  5. 5Read and compare implementations. Study the source and compare alternative implementations of the same problem.
  6. 6Compile and run. Build the file with your C++17 compiler and follow the execution details in its documentation.

What C-Plus-Plus is and who it is for

The repository collects implementations of many algorithms in C++, licensed under the MIT License. The code and its documentation are written as a learning resource, so the same problem may appear more than once, each solved with a different strategy or optimization.

It suits students learning algorithms and data structures in C++, educators who want example code to teach from, and developers preparing for technical interviews or competitive programming. It is not a production library to call from an application, and it is not a packaged tool with an installer or release versions.

What you need before you start

The README lists one prerequisite for the install method it describes: a C++17-capable compiler. Each source file uses only the STL (standard template library), so no external libraries are required to compile and run the code.

You should already know some C++, because the code and explanations assume it.

  • A C++17-capable compiler
  • Git, to clone the repository (the README gives a git clone command)
  • Basic C++ knowledge

Clone the repository

The README's install method is clone-and-build. Run the command below to copy the repository to your machine. The project's documentation site is at https://thealgorithms.github.io/C-Plus-Plus.

git clone https://github.com/TheAlgorithms/C-Plus-Plus

Find and study an algorithm

Browse the repository files to find the topic you want. The online documentation is generated from the source code and includes source snippets, details on how to run the programs, diagrams of program flow, and links to external resources. Its Files menu lists every documented file.

Because several implementations of one problem may exist, compare them to see how different strategies and optimizations change the code.

  • Open the online documentation at https://thealgorithms.github.io/C-Plus-Plus
  • Use the Files menu to see all documented files
  • Compare two implementations of the same problem side by side

Compile and run a program

The README says the code is compiled and tested on Windows (MSVC 19 2022), macOS (AppleClang 15.0.15) and Ubuntu Linux (GNU 13.3.0), and that it follows the C++17 standard. Use a compiler with C++17 support. The README does not give a specific build command, so consult the individual file's documentation for how to run it.

Many files include self-checks that verify the implementation is correct.

  • Use a compiler that supports C++17
  • Check each file's documentation for execution details
  • Look for the built-in self-checks to confirm results

Contribute or reuse the code

The project is community developed and welcomes new, original, quality contributions. Read the Contribution Guidelines before submitting. Because the code is MIT licensed, you may reuse the modular implementations in other applications under the license terms. The documentation itself is licensed under CC BY-SA 4.0.

  • Read CONTRIBUTING.md before opening a contribution
  • Check the MIT License before reusing code

What people use it for

  • A student working through sorting or searching algorithms in C++
  • An educator selecting example implementations for a lecture
  • A developer practising problems for a technical interview
  • A programmer comparing different strategies for the same problem

Frequently asked questions

Is C-Plus-Plus free to use?

Yes. The repository is licensed under the MIT License, which the README links to. The documentation is licensed under CC BY-SA 4.0.

What do I need to install C-Plus-Plus?

The README's install method is clone-and-build, with a C++17-capable compiler as the prerequisite. Run git clone https://github.com/TheAlgorithms/C-Plus-Plus to get the code.

Does C-Plus-Plus need external libraries?

No. The README states that each source code uses STL classes and no external libraries are required for compilation and execution.

Can I use C-Plus-Plus in a production application?

The README frames the code as educational. It is meant for studying algorithms rather than as a production library to call from an application, so choose another option for production work.

Is there an installer or release version?

The README mentions no releases or installer. You get the code by cloning the repository.

How does C-Plus-Plus compare with TheAlgorithms Python or Java?

The comparable projects are TheAlgorithms/Python, TheAlgorithms/Java and TheAlgorithms/JavaScript. The source does not compare them in detail, so review each repository to choose the language you want to learn.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

C-Plus-Plus is a good fit for students, educators and interview or competitive programmers who know C++ and want to study many algorithms with documented, STL-only code under a permissive licence. It is not suited to anyone who needs a production library, a packaged installer, or who is not comfortable reading C++.

Install options & downloads