Early previewThis guide is in development. Items tagged verify are still being checked against official docs.
nebx Learn
GitHub
Menu
Home/C++/Basics
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)

Basics

The concepts you need before patterns make sense in C++.

Compile, link, run

Source files (.cpp) are compiled to object files and linked into a native executable. Headers (.h/.hpp) declare interfaces; build systems such as CMake orchestrate the process.

#include <iostream>

int main() {
    std::cout << "Hello, patterns!\n";
}

RAII

Resource Acquisition Is Initialization: a resource (memory, file, lock) is tied to an object's lifetime and released in its destructor. This is the foundation of safe C++.

Values, references, pointers

Objects are values by default and copied on assignment. References (T&) alias an object; pointers (T*) may be null and re-seated. Move semantics (T&&) transfer ownership cheaply.

Smart pointers

std::unique_ptr expresses single ownership, std::shared_ptr shared ownership with reference counting. Raw pointers should only observe, never own.

Templates and the STL

Templates generate code per type at compile time. The Standard Library gives containers (vector, map, unordered_map), algorithms and ranges. C++20 concepts constrain templates with readable errors.

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