Glossary
10 min read
Appendix D: Glossary
Terms used in this book, in alphabetical order. Each definition is brief and practical — this is not a language-lawyer specification, but a quick reference for when you encounter a term and want a one-sentence reminder.
Abstract class
A class that has at least one pure virtual function (= 0). You cannot create instances of an abstract class directly; you must derive a class that implements all pure virtual functions.
ABI (Application Binary Interface)
The low-level contract between compiled code units: how functions are called, how objects are laid out in memory, how exceptions are handled. Changing a class layout can break ABI compatibility without changing the API.
ADL (Argument-Dependent Lookup)
Also called Koenig lookup. When you call a function without a namespace qualifier, the compiler also searches in the namespaces of the argument types. Enables operator<< and swap to be found in the right namespace automatically.
Aggregate initialization
Initializing a struct or array using a braced list: Point p{1.0, 2.0};. Works when the type has no user-provided constructors.
Alias (type alias)
A new name for an existing type: using Seconds = double;. Introduced with using (modern) or typedef (older).
Allocator
An object that controls memory allocation for a container. std::vector<T> uses std::allocator<T> by default, which calls new and delete. Custom allocators are used in performance-critical or embedded code.
Arithmetic conversion
Implicit conversion between numeric types in expressions: int + double promotes the int to double. Can cause surprises with signed/unsigned mixing.
auto
A placeholder for a type that the compiler deduces from the initializer. The type is still fixed at compile time. auto x = 42; declares x as int.
Base class
A class from which another class (the derived class) inherits. Also called the parent class or superclass.
Big O notation
A way of describing algorithm complexity. O(1) is constant time; O(log n) is logarithmic; O(n) is linear; O(n log n) is typical for good sorting; O(n²) is quadratic.
CTAD (Class Template Argument Deduction)
C++17 feature. The compiler deduces template arguments from constructor arguments: std::vector v{1, 2, 3} instead of std::vector<int> v{1, 2, 3}.
Capture list
The [...] part of a lambda that specifies which variables from the surrounding scope the lambda can access and whether they are captured by value or reference.
consteval
C++20. A function that must be evaluated at compile time. Calling it with runtime arguments is an error.
constexpr
A function or variable that can be evaluated at compile time. A constexpr function may also run at runtime if given non-constant arguments.
Constructor
A special member function that initializes an object when it is created. Named the same as the class, no return type. A class may have multiple constructors (overloads).
Copy constructor
A constructor that creates a new object as a copy of an existing one: MyClass(const MyClass& other). Generated by the compiler if not provided, unless the class has a move constructor or move assignment.
Copy elision / RVO (Return Value Optimization)
A compiler optimization that eliminates unnecessary copies of objects returned from functions. Mandatory in C++17 in many cases.
Dangling reference / dangling pointer
A reference or pointer that refers to memory that has been freed or gone out of scope. Accessing a dangling reference/pointer is undefined behavior.
Data race
Two threads accessing the same memory location concurrently, with at least one writing, and no synchronization. Undefined behavior. Use mutexes or atomics to prevent.
Decltype
A keyword that returns the declared type of an expression: decltype(x + y) gives the type of the expression x + y.
Default constructor
A constructor callable with no arguments: MyClass(). Generated by the compiler if no other constructors are provided.
Derived class
A class that inherits from a base class. The derived class has all the base class's public and protected members, and may add its own or override virtual functions.
Destructor
A special member function called when an object's lifetime ends (goes out of scope or is explicitly destroyed). Named ~ClassName(). Used for cleanup (RAII).
Dynamic dispatch / virtual dispatch
Selecting which function implementation to call at runtime, based on the actual type of the object rather than the static type of the pointer or reference. Enabled by virtual functions.
Dynamic memory / heap
Memory allocated at runtime with new and freed with delete. Contrast with the stack (automatic storage duration). Smart pointers manage heap memory automatically.
Encapsulation
Grouping data and the functions that operate on it inside a class, and hiding implementation details behind a public interface.
Enum class (scoped enumeration)
A strongly typed enumeration whose enumerators live in the enum's own scope and do not implicitly convert to integers. enum class Color { Red, Green, Blue };
Exception safety
A guarantee about what happens to program state when an exception is thrown. Three levels: basic (no leaks), strong (rollback), nothrow (never throws).
explicit
A keyword on single-argument constructors (and conversion operators) that prevents implicit conversion: explicit Buffer(size_t n) means you cannot write Buffer b = 100;.
Fold expression
C++17. Applies a binary operator across all arguments of a parameter pack: (args + ...) sums all args.
Forward declaration
Declaring a type or function without providing its definition. Allows using a pointer or reference to a type without including its full header.
Friend
A function or class granted access to the private and protected members of a class. friend std::ostream& operator<<(...).
IIFE (Immediately Invoked Function Expression)
A lambda called at the point of definition: auto result = [&]() { ... return val; }();. Useful for complex initialization of const variables.
Implicit conversion
A type conversion performed automatically by the compiler without an explicit cast. int to double, derived pointer to base pointer, etc.
Initializer list (std::initializer_list)
The type behind braced initialization with multiple values: {1, 2, 3}. Functions and constructors can take std::initializer_list<T>.
Inline function
A function whose body is expanded at the call site, eliminating the function call overhead. The inline keyword is also used to allow definitions in headers without violating the One Definition Rule.
Invariant
A condition that is always true about an object's state. A class enforces invariants through its constructor and access control.
Iterator
An object that points to an element in a container and supports ++ (advance), * (dereference), and == (comparison). Provides the interface used by standard algorithms.
Lambda (lambda expression)
An anonymous function defined inline: [capture](params) { body }. Can capture variables from the enclosing scope.
Lifetime
The period between an object's construction and destruction. Stack objects have automatic lifetime; heap objects have dynamic lifetime (until delete is called or the smart pointer is destroyed).
Linkage
Controls which names are visible across translation units. Internal linkage (anonymous namespace, static) means visible only in the current file. External linkage (the default for most names) means visible to the linker.
lvalue / rvalue
Loosely: an lvalue is something that has a name (and whose address you can take). An rvalue is a temporary (like the result of a + b). Move semantics use rvalue references (T&&) to detect temporaries.
Member initializer list
The : member_{value} syntax after the constructor signature that initializes members before the body runs. More efficient than assignment in the constructor body.
Move constructor
A constructor that transfers resources from a temporary (rvalue) object: MyClass(MyClass&& other) noexcept. Avoids copying for classes that own heap resources.
Move semantics
The ability to transfer (rather than copy) the contents of an object. Enables efficient return by value and movement into containers. Triggered by rvalue references and std::move.
Namespace
A named scope that groups related declarations and prevents name collisions. std:: is the namespace for the standard library.
noexcept
A specifier declaring that a function will never throw. If it does, std::terminate is called. Critical for move constructors (enables vector reallocation optimization).
[[nodiscard]]
An attribute that causes a warning if the return value of a function is discarded. Used for error codes and results that callers must check.
nullptr
The null pointer constant in C++11 and later. Prefer over NULL or 0 — it is type-safe (type std::nullptr_t).
ODR (One Definition Rule)
A rule stating that each entity (function, class, template) may have only one definition across the entire program (with exceptions for inline functions and templates in headers).
Override
The override keyword on a derived-class virtual function declaration confirms that you are overriding a base-class virtual function. The compiler errors if no matching virtual function exists.
Overloading
Multiple functions or operators with the same name but different parameter types. The compiler picks the right one at each call site.
Parameter pack
A template parameter that matches zero or more arguments: typename... Args. Used in variadic templates.
Pointer
A variable that holds the memory address of another object. Declared with *. Dereferenced with *. The address of a variable is obtained with &.
Polymorphism
The ability to treat objects of different derived types uniformly through a base class pointer or reference. Virtual dispatch selects the correct derived implementation at runtime.
RAII (Resource Acquisition Is Initialization)
A pattern where a resource (memory, file, lock) is acquired in a constructor and released in the destructor. Ensures cleanup happens even when exceptions are thrown.
Range (C++20)
Anything that provides begin() and end() iterators. Standard algorithms in <ranges> work on ranges directly without requiring explicit begin/end.
Reference
An alias for an existing object. Cannot be null; cannot be reseated. Declared with &. const T& is the standard way to pass large objects to functions efficiently.
Rule of Zero / Three / Five
Guidelines for when to define special member functions. Rule of Zero: use smart pointers and standard containers and define none. Rule of Three: if you define one of destructor/copy constructor/copy assignment, define all three. Rule of Five: adds move constructor and move assignment.
Scope
The region of code in which a name is visible. Block scope (inside {}), function scope, class scope, namespace scope, global scope.
SFINAE (Substitution Failure Is Not An Error)
A template metaprogramming technique where a substitution failure during overload resolution silently removes a candidate rather than producing an error. Largely superseded by Concepts in C++20.
shared_ptr
A smart pointer with shared ownership. Reference-counted: the managed object is destroyed when the last shared_ptr to it is destroyed.
Slicing
Assigning a derived class object to a base class object by value, silently discarding the derived members. Prevented by working with pointers or references.
Smart pointer
A class that wraps a raw pointer and automates its lifetime management. unique_ptr and shared_ptr are the standard library smart pointers.
Stack
Fast, fixed-size memory for local variables. Automatically managed: objects are destroyed when they go out of scope.
std::move
A cast to an rvalue reference that enables move semantics. Does not itself move anything; the move constructor or assignment operator does the actual work.
std::optional
A container that holds either a value or nothing (std::nullopt). The standard replacement for "nullable" types without using pointers.
std::expected
C++23. A type that holds either a value or a typed error. Richer than optional, cheaper than exceptions for high-frequency failure paths.
Template
A blueprint for generating type-specific code at compile time. Function templates and class templates generate separate implementations for each type they are instantiated with.
Translation unit
A single .cpp file after preprocessing (including all #included headers). The compiler compiles one translation unit at a time.
Type deduction
The compiler automatically determining the type of an expression or template parameter. auto, decltype, and template argument deduction all use type deduction.
Undefined behavior (UB)
A program state that the C++ standard does not constrain — the compiler may do anything. Common sources: null pointer dereference, out-of-bounds access, signed integer overflow, data races. Sanitizers (-fsanitize=address,undefined) catch many at runtime.
unique_ptr
A smart pointer with exclusive (single) ownership of a heap object. Non-copyable, movable. The managed object is destroyed when the unique_ptr goes out of scope.
Virtual function
A member function declared virtual in a base class. When called through a base pointer or reference, the implementation selected at runtime corresponds to the actual derived type of the object.
weak_ptr
A non-owning observer of a shared_ptr-managed object. Does not affect the reference count. Use lock() to get a temporary shared_ptr if the object is still alive. Used to break reference cycles.