C++ glossary – key terms explained
Compiler
Translates C++ source code into machine code (object files), e.g. g++, clang++ or MSVC.
Concept
C++20 language feature that names requirements on template types (std::integral) and provides clear error messages.
const correctness
Consistent use of const for everything that should not change (variables, parameters, methods). The compiler enforces the promise.
constexpr
Marks values and functions that can already be computed at compile time.
Dangling reference
Reference or pointer to an object that has already been destroyed. Accessing it is undefined behavior.
Header file
File (.hpp/.h) that contains declarations and is included via #include. The definitions are usually in the corresponding .cpp.
Iterator
Object that points to an element of a container and can be advanced (begin(), end()). Connects containers with algorithms.
Lambda
Anonymous function defined in place: capture{ body }. Can capture variables from the surrounding scope.
Linker
Joins object files and libraries into an executable program and resolves symbols.
lvalue / rvalue
lvalue: expression with identity whose address can be taken (variable). rvalue: temporary value (result of a computation) that may be moved from.
Move semantics
Transferring resources from one object to another instead of copying them (rvalue references, std::move).
Pointer
Variable that holds the memory address of an object (int* p = &x;). Can be nullptr and can be redirected.
RAII
Resource Acquisition Is Initialization: resources are acquired in the constructor and released in the destructor. The basis for smart pointers, streams and lock guards.
Reference
Alternative name for an existing object (int& r = x;). Must be initialized and cannot be redirected.
Rule of Zero / Five
Zero: hold resources in self-managing members, write no special functions. Five: if you write any one of destructor, copy/move constructor or assignment yourself, you should consider all five.
Sanitizer
Compiler tool (-fsanitize=address,undefined,thread) that reports memory errors, UB and data races at runtime.
Slicing
When a derived object is copied into a base class variable, the derived part is cut off; polymorphism is lost.
Smart pointer
Object that behaves like a pointer but regulates ownership: unique_ptr, shared_ptr, weak_ptr.
STL
Standard Template Library: containers (vector, map), iterators and algorithms (sort, find) of the standard library.
Template
Blueprint for functions or classes that is instantiated for arbitrary types – at compile time, with no runtime cost.
Undefined behavior (UB)
Construct for which the standard makes no statement (dangling, overflow, data race). The program may do anything – including seemingly running correctly.
virtual / polymorphism
With virtual, calls through a base pointer or reference select the method of the actual class at runtime.