Programming foundations: C++

Sefism.

A to Z

Glossary

Every concept in this sheet, plus the smaller terms it uses. Select a concept to open its card.

#
.gitignore
A file listing patterns of files and folders Git should not track, such as dependencies, build output, logs and local secrets.
A
Arrays and amortised growth
An array stores items side by side in memory, so reading by index is O(1).
B
Big-O notation
Big-O describes how the running time or memory of an algorithm grows as the input size n grows, ignoring constants.
Binary search
Searching a sorted array by checking the middle element and discarding the half that cannot contain the target, until it is found or the range is empty.
Bits, bytes and binary
A bit is a 0 or 1.
Branches
A branch is a movable name that points to a commit.
C
Calling a public API
Sending an HTTP request (usually GET or POST) to a web service and reading its response, typically a status code plus a JSON body.
Classes and objects
A class is a blueprint that groups data (fields) with the behaviour that works on it (methods).
CMake
CMake describes how to build a C++ project in CMakeLists.txt and generates the real build files for your platform.
Code smells and refactoring
A code smell is a sign of a deeper design problem: long functions, duplicated blocks, many parameters, deep nesting.
Comments, docstrings and READMEs
Comments explain why code does something non-obvious.
Commit messages
A short summary line in the imperative mood (about 50 characters), a blank line, then a body that explains why the change was made.
Compiled and interpreted code
A compiler translates source to machine code before running (C++).
Compiling and linking
The compiler turns each .cpp file into an object file, and the linker joins object files and libraries into one executable.
Conditionals
Code that runs only when a condition is true, with else if branches checked in order and an optional else for everything left.
Configuration and secrets
Settings that change between machines (API keys, URLs, file paths) are read from environment variables or a local config file instead of being written into the code.
D
Dictionaries and maps
A collection of key and value pairs where you look a value up by its key, such as a product name to its stock count.
DRY, KISS and YAGNI
DRY: keep each piece of knowledge in one place.
E
Edge cases
Inputs at or beyond the limits of normal use: empty collections, zero, negative numbers, one item, very large values, missing fields and unexpected text.
Encapsulation
Keeping an object's data private and exposing only the operations that keep it valid.
Exceptions
An exception is an error object thrown when something goes wrong.
F
Floating point numbers
Floats store numbers in binary with limited precision, so most decimal fractions such as 0.1 are approximations.
Functions
A named block of code that takes inputs (parameters), does one job and can return a result.
G
Graphs
A graph is a set of nodes (vertices) connected by edges, which may have directions or weights.
H
How hash tables work
A hash table turns a key into a number with a hash function, uses it to pick a bucket in an array, and stores the entry there.
How the CPU runs a program
The CPU repeatedly fetches an instruction from memory, decodes it and executes it: simple steps such as add, compare, jump and copy.
I
Inheritance and composition
Inheritance builds a class from a parent class and reuses its code ("is a").
Integer overflow
Fixed-size integers have a maximum.
Interfaces and polymorphism
An interface is a contract listing methods a type must provide.
L
Linked lists
A chain of nodes where each node holds a value and a pointer to the next (and, in a doubly linked list, the previous) node.
Lists and dynamic arrays
An ordered collection that grows as you add items and gives fast access by index: list in Python, arrays in JavaScript, ArrayList in Java, std::vector in C++ and List<T> in C#.
Loops
A loop repeats a block of code: a for-each loop visits every item in a collection, a counting for loop runs over a range of indexes, and a while loop repeats as long as a condition holds.
M
Merge conflicts
A conflict happens when two branches changed the same lines.
Merging and rebasing
Merging joins another branch into yours, adding a merge commit if both changed.
Modules and imports
A module is a file (or group of files) of related code that other files import by name.
Move semantics
Moving transfers the resources of an object (such as the buffer of a string) to another object instead of copying them.
Mutability and copying
A mutable value can change in place; an immutable one cannot.
N
Naming and small functions
Names that say what a value is or what a function does (unpaid_invoices, send_reminder), and functions short enough to do one thing at one level of detail.
Null and missing values
A special value meaning "nothing here": None in Python, null and undefined in JavaScript, null in Java and C#.
P
Passing arguments to functions
Python, JavaScript and Java always pass a copy of the value, but for objects that value is a reference, so the function can change the object but not rebind your variable.
Pointers
A pointer holds the memory address of an object.
Processes and threads
The operating system runs each program as a process with its own memory.
Publishing on GitHub
Pushing a project to a public GitHub repository with a README, a licence, a .gitignore and a clean history of meaningful commits.
Pull requests
A pull request asks to merge one branch into another on GitHub.
Q
Queues and deques
A queue is first-in, first-out: add at the back, remove from the front, both O(1).
R
RAII
RAII ties a resource (memory, file, lock) to an object: the constructor acquires it and the destructor releases it when the object goes out of scope, even if an exception is thrown.
Reading and validating input
Reading text typed by a user or passed to the program, then converting it to the type you need, such as an integer, and rejecting anything that does not fit.
Reading and writing JSON
JSON is a text format for objects, arrays, strings, numbers, booleans and null.
Reading errors and debugging
A stack trace lists the chain of function calls that led to an error, with file names and line numbers.
Reading files and cleaning up
Files, network connections and locks must be closed when you are done, even if an error happens halfway.
Recursion
A function that calls itself on a smaller version of the problem, with a base case that stops the calls.
References and const
A reference (T&) is another name for an existing object.
Remotes: clone, fetch, pull and push
A remote is a copy of the repository on a server such as GitHub, usually named origin.
Repositories and commits
A Git repository stores the full history of a project.
S
Scope
Scope is the part of the code where a name is visible.
Scoping a small project
Cutting an idea down to the smallest version that solves one real problem end to end, then splitting it into a handful of milestones.
Separation of concerns
Splitting a program so each part handles one concern: reading input, business logic, storage and output live in separate functions or modules.
Sets
An unordered collection of unique values with fast membership checks.
Shell navigation
The shell is a text interface for running programs and working with files.
Smart pointers
std::unique_ptr is the single owner of a heap object and deletes it automatically.
SOLID
Five design principles: a class has one reason to change; extend behaviour without editing working code; subtypes must work wherever the parent does; keep interfaces small; depend on abstractions rather than concrete details.
Stack and heap
The stack holds each running function's local variables in frames that vanish when it returns.
Stacks
A last-in, first-out collection: you push onto the top and pop from the top, both O(1).
Staging area
The staging area holds the changes that will go into the next commit.
Static and dynamic typing
Statically typed languages (Java, C++, C#) check types when the code is compiled.
Strings and formatting
A string is a sequence of text characters.
T
Test doubles
Stand-ins for real dependencies in tests: a stub returns fixed answers, a fake is a simple working version (an in-memory store), and a mock checks how it was called.
Test-driven development
Writing a failing test first (red), then the least code that makes it pass (green), then cleaning up (refactor), in short cycles.
Text encoding and Unicode
Unicode gives every character a number (a code point).
The test pyramid
A guideline for balancing test types: many fast unit tests, fewer integration tests that check parts working together, and a few slow end-to-end tests through the whole system.
Trees and binary search trees
A tree is a hierarchy of nodes with one root, where each node has children and no cycles.
U
Undefined behaviour
Code the C++ standard places no requirements on, such as reading out of bounds, using uninitialised variables, signed integer overflow or using a destroyed object.
Undoing mistakes
restore discards uncommitted changes to a file, commit --amend fixes the last commit, revert adds a commit that undoes an old one, reset moves your branch back, and reflog lists where HEAD has been.
Unit tests
Small automated tests that call one function or class with known input and assert on the result.
V
Variables and types
A variable is a name that refers to a value.
W
Writing a README
The front page of a repository: what the project does and for whom, a demo, how to install, run and test it, how it works and its known limits.
10 · Glossary, A to Z10 / 10