Skip to content

Programming Notes | C++ - Wyatt's Notes

Deep systems programming notes covering ownership, templates, concurrency, and build systems.

Compilation Model

Types

Resource Management

Object Oriented

Standard Library

Concurrency

How to Use These Notes

  1. Start with the fundamentals — build a solid foundation before moving to advanced topics
  2. Work through examples — follow along with the worked examples to build intuition
  3. Test yourself — use the practice problems and flashcards to check your understanding
  4. Review regularly — spaced repetition helps retain what you have learned

Common Mistakes

Forgetting rule of zero/three/five: If your class manages a resource, define or delete the copy constructor, copy assignment, move constructor, and move assignment. If it does not, the compiler-generated defaults may silently cause double-free bugs or shallow copies of owned resources.

Using raw new/delete instead of RAII: Manual memory management with new and delete is error-prone — exceptions, early returns, and forgotten cleanup cause leaks and dangling pointers. Use smart pointers (std::unique_ptr, std::shared_ptr) and stack allocation to bind resource lifetime to scope.

Assuming std::move moves data: std::move casts an lvalue to an rvalue reference — it does not itself move anything. The actual move happens in the move constructor or move assignment operator of the target type. Misusing std::move on objects after they have been moved-from leads to undefined or surprising behaviour.

Cross-References

Intuition

C++ is a language built on the principle that you should not pay for what you do not use. Unlike managed languages that provide runtime services (garbage collection, bounds checking, virtual dispatch) whether you need them or not, C++ gives you precise control over every aspect of your program: memory layout, calling conventions, compile-time vs runtime computation, and resource lifetimes. This control is the source of both C++‘s power and its complexity — every feature exists because someone needed it, and understanding why a feature exists is the key to knowing when to use it.

The notes are structured around the central concern of systems programming: managing resources correctly and efficiently. The compilation model explains how source code becomes machine code. The type system explains how data is represented and constrained. Resource management explains how to avoid leaks, dangling references, and undefined behaviour. The standard library provides tools built on these foundations. Object-oriented programming and concurrency add layers of abstraction for specific problem domains. Each section builds on the previous ones, forming a coherent mental model of the language.

When studying, start with the compilation model and types — these are the foundations everything else depends on. Then move to resource management (RAII and ownership), which is the single most important concept in C++. Templates and the standard library build on top of these foundations. The common mistakes and cross-references throughout the notes are designed to help you see connections between sections and avoid the pitfalls that trap even experienced C++ programmers.