Part 4 addresses the central problem in systems programming: who is responsible for releasing a Resource, and when does that release occur?
In garbage-collected languages, the runtime answers this question for you. In C++, the programmer Must establish explicit ownership contracts. When these contracts are violated, the result is a Resource leak, a double-free, or use-after-free — all of which are undefined behavior.
This part covers four tightly coupled topics:
Ownership and RAII (Module 10): The idiomatic C++ mechanism that binds resource lifetime to scope. Covers std::unique_ptr``std::shared_ptr``std::weak_ptrAnd custom deleters.
Value Categories and Move Semantics (Module 11): The type system machinery that enables efficient transfer of resources between scopes without copying. Covers lvalues, rvalues, move constructors, RVO, and perfect forwarding.
Function Architecture (Module 12): How ownership interacts with function boundaries. Parameter passing, return values, lambdas, and C FFI.
Error Handling (Module 13): Exception safety guarantees, noexceptAnd the modern algebraic alternatives (std::expected``std::variant).
## Related Topics
Rust Ownership and Borrowing — Rust”s compile-time ownership model as an alternative to C++ manual resource management.
Unsafe Rust — When Rust’s safety guarantees are deliberately bypassed.
Resource management is the central challenge in C++ programming: who owns a resource and when is it released? In garbage-collected languages, the runtime handles this. In C++, you must establish explicit ownership contracts. RAII (Resource Acquisition Is Initialization) binds resource lifetime to scope: when an object goes out of scope, its destructor runs and releases the resource. Smart pointers (unique_ptr, shared_ptr) extend this to heap memory. Move semantics let you transfer ownership without copying, eliminating unnecessary duplication.