The -> operator
-> operator — shorthand for dereferencing a pointer and accessing a member. Equivalent to (*pointer).member. Building a class with a header file
enum class
You can think of these as a variable, but ahead of time it is constrained to a specific set of values. Definition of a Dangling Pointer
Dangling pointer — a pointer that points to memory that no longer belongs to you. The object it pointed to has been destroyed, but the pointer still holds its old address. Address of Operator
Definition of a Caller
Caller — the function that calls another function. static_cast
A C++ operator that explicitly converts a value from one type to another at compile time, making the conversion visible and intentional in the code. It is safer than a C-style cast because the compiler checks that the conversion is valid. It is used when you need to convert between related types such as int and float, or long and int. Direct versus copy initialization of a constructor
Direct initialization T b(a) and copy initialization T b = a are two syntax styles that both invoke the copy constructor to create a new object from an existin…Direct initialization T b(a) and copy initialization T b = a are two syntax styles that both invoke the copy constructor to create a new object from an existing one. They produce the same result — a new object constructed as a copy of a. Operator=
operator= defines what happens when you use = on an object.operator= defines what happens when you use = on an object. It takes a reference to another object of the same type and returns a reference to itself via return *this, enabling chained assignments like c = b = a. Default parameter values
static
Signals that a value belongs to the class, not any instance, and is fixed at compile time. const placed after a member function
A const placed after a method signature means the function is read-only — it cannot modify any member variables of the object. It acts as a guardrail, forcing the compiler to catch accidental modifications inside the function. Use it on any method that only needs to read state, such as getters, to make your intent clear and your code safer. Definition of a Non-Static Member Function
A non-static member function is a function that belongs to a specific instance of a class, and always operates on that instance through this. Passing Functions (Callbacks)
In C++, functions can be passed as parameters to other functions using function pointers, allowing you to decide what code runs without hardcoding it. The receiving function holds onto the address of the passed function and calls it at the right time. This is the foundation of event-driven programming, where you say "call this function when something happens" Defnition of a Thread
An independent sequence of execution within a program. The OS can run multiple threads concurrently, each doing their own work, while sharing the same memory. L values (Left Values)
An lvalue (locator value) is an expression that refers to a memory location and can appear on the left-hand side of an assignment. It represents an object that persists beyond a single expression — it has an identifiable address in memory. Definition of a Static Method
A static method is a function that belongs to the class itself rather than to any instance of it. It has no access to instance attributes and can be called without ever creating an object. Definition of a Signature
A function signature in C++ is the part of a function declaration that identifies it uniquely to the compiler. It consists of: Function name Parameter types (number, order, and types) Reference declaration (in type declarations)
bitwise OR assignment operator
Bitwise OR assignment (|=) — takes the existing bits of the left operand, ORs them column by column with the bits of the right operand, and stores the result b…Bitwise OR assignment (|=) — takes the existing bits of the left operand, ORs them column by column with the bits of the right operand, and stores the result back into the left operand. Can only turn bits on, never off. Constant Member Functions
Guarantees the method will not modify any member variables. Macros
A preprocessor directive defined with #define that is expanded before the compiler sees the code. It is not a function or a class, and can be used for text substitution, constants, or conditional compilation. Macros are considered old fashioned in modern C++ but are still used in cases where compile time behaviour is needed. The Two Main Ways of Initializing a Function
Passing This to Other Objects
Anytime a class the keyword "this" is implicit and automatic. Once a class has to pass data from the class into another object the "this" keyword has to be passed. Endless For-Loop
Lambda Functions
The brackets tell the lambda which variables from the surrounding scope it's allowed to use, and how it remembers them. By default, a lambda body cannot see any local variable from the function it's written inside. The capture list is how you grant access, one variable (or one default rule) at a time. Constructing an obect in C++
This is how it would look in Python: variable_name = ClassName(constructor_arguments) Dereferencing a Pointer
The * in front of a pointer means "go to the address this pointer holds and give me what's there." Range Based For-Loops
A range-based for loop is a loop that iterates over every element in a collection, from the first to the last, without needing to manually manage an index or i…A range-based for loop is a loop that iterates over every element in a collection, from the first to the last, without needing to manually manage an index or iterator. const — omit if you need to modify <element> & — omit if you want a copy of each element rather than a reference Template Functions
Try Catch
catch(...). This is for any unkown exception that can't be caught by an std::exception. Template Aliases
=delete
= delete explicitly forbids a function from being used, turning a potential runtime crash into a compile time error.= delete explicitly forbids a function from being used, turning a potential runtime crash into a compile time error. constexpr
constexpr declares a value that is fixed and known at compile time, meaning the compiler bakes it directly into the binary rather than storing it in memory. This eliminates any runtime cost of looking up the value, since the compiler simply substitutes it wherever it appears in the code. It also makes intent explicit — clearly signaling to other developers that this value is a compile time constant that will never change. Factory Method
A static method that constructs and returns an object, hiding the construction details from the caller. Member Initializer List
A way to set a class's member variables before the constructor body runs. Uses a colon after the constructor parameters, with each member and its starting value in parentheses. std::move can be used instead of copying when transferring ownership of data. What goes in the (): The value you want the member to start with. This is usually the matching constructor parameter, but can also be a literal value like 0 or "default". Commenting Out Unused Parameters in C++
When a function signature is fixed and you can't change it, but don't need all the parameters, comment out the name to suppress unused warnings while keeping the type. |
Cheatography
https://cheatography.com
C++ Cheat Sheet (DRAFT) by blakecromar
A cheatsheet for C++
This is a draft cheat sheet. It is a work in progress and is not finished yet.