Functions, references and containers

This part of the C++ course is about the values a function takes and the containers that keep them. A reference and const correctness come first, then overloading and recursion, the namespace, and the lifetime of a variable. The standard library follows: std::string and std::vector, a fixed-size std::array and a view over them, the type deduction that saves a name, an enumeration, and the bits of an integer with std::bitset.

2.1 References a reference as another name for an object, references as parameters, and when a copy is the better choice Open 2.2 const and const correctness const variables, const references, pointers to const, const members of an API and constexpr values Open 2.3 Overloading and default arguments overload resolution on parameter types, default arguments, ambiguities and the errors they print Open 2.4 Recursion a base case, a recursive step, factorials, the call stack, and a recursion that runs out of stack Open 2.5 Namespaces declaring a namespace, qualified names, using declarations, nested namespaces and the anonymous namespace Open 2.6 Scope and lifetime block scope, static local variables, global objects, thread_local and the order of destruction Open 2.7 std::string construct, append, find, substr, compare, convert numbers and walk the characters of a string Open 2.8 std::string_view a view over existing characters, substr without copying, dangling views and when to pass a view Open 2.9 std::vector size and capacity, push_back, reserve, indexing, erase and the cost of growing Open 2.10 std::array, C arrays and std::span fixed-size arrays on the stack, std::array as a value type, and std::span for a read-only window Open 2.11 auto, decltype and structured bindings type deduction, the difference between auto and auto&, decltype and unpacking pairs and structs Open 2.12 Enumerations unscoped enums, enum class, underlying types, switch over an enum and printing a name Open 2.13 Bits, bit fields and std::bitset bitwise operators as flags, shifts, std::bitset, bit fields in a struct and their layout Open

Lessons