Early previewThis guide is in development. Items tagged verify are still being checked against official docs.
nebx Learn
GitHub
Menu
Home/C++/Best practices
C++

C++

Zero-cost abstractions and full control over memory.

Paradigm
Multi-paradigm, OOP, generic
Typing
Static, strong-ish
Memory
Manual / RAII, no GC
Runs
Native machine code (AOT)
Concurrency
Threads, atomics, coroutines (C++20)

Best practices

Habits experienced C++ teams agree on.

Follow the C++ Core Guidelines

Maintained by Bjarne Stroustrup and Herb Sutter; tools like clang-tidy can check many of the rules.

Rule of zero

Let members (vector, unique_ptr, string) manage resources so your class needs no custom destructor, copy or move.

Const correctness

Mark methods and references const wherever possible; it documents intent and enables optimisation.

Turn on warnings and sanitizers

Build with -Wall -Wextra -Werror in CI and run tests under AddressSanitizer and UndefinedBehaviorSanitizer.

Use a package manager

vcpkg or Conan with CMake gives reproducible dependency builds instead of vendored copies.

Saved in this browser only. Part of Clean code foundations (0/5).