Modern C++ Tutorials for Raspberry Pi¶
This series uses Raspberry Pi examples to explain C++ syntax, resource lifetimes, build tools, and standard-library features.
This C++ series covers language basics, resource management, standard-library containers and algorithms, and features from C++17 through C++23. Examples use a Raspberry Pi development environment.
Why Learn Modern C++?¶
Modern C++ includes the following approaches:
- Memory Safety: Moving away from raw pointers and manual memory management (new/delete) to value semantics and smart pointers.
- Developer Expressiveness: Using type inference (auto), lambda expressions, and robust standard library utilities to write cleaner, more readable code.
- Zero-Overhead Abstractions: Coding at a high level of abstraction without sacrificing performance or control over hardware.
Course Roadmap¶
After the language foundations, use Data-Oriented Design & ECS to compare C++ representations with a shared simulation and executable tests. It is a separate design course, not a prerequisite for learning the language.
The curriculum is structured into four sequential parts, building your knowledge from syntax foundations up to advanced features.
Part 1: Foundations¶
Start with syntax, control flow, functions, and compile-time expressions.
- Introduction & Environment Setup — Compiler installation on Raspberry Pi, understanding compilation phases, and building your first program.
- Basic Syntax — Variables, types, const vs constexpr, type inference, and bindings.
- Control Flow — Conditional structures, loops, and modern flow control improvements.
- Functions — Parameters, call-by-value vs call-by-reference, function overloading, and lambdas.
- Operators — Standard operators and C++20 three-way comparison (<=>).
- Pointers and References — Navigating address spaces, reference semantics, and how pointer arithmetic maps to hardware.
Part 2: Memory & Object-Oriented Programming¶
Understand how objects interact and how memory is allocated and freed.
- Memory Management — Deep dive into Stack vs Heap, Resource Acquisition Is Initialization (RAII), and modern smart pointers (std::unique_ptr, std::shared_ptr).
- Classes and Objects — Encapsulation, constructors/destructors, member initialization lists, and class design.
- Inheritance — Polymorphism, virtual functions, vtables, and memory layout of derived classes.
- Operator Overloading — Defining custom behavior for operators and implementing the Copy-and-Swap idiom.
Part 3: The Standard Library (STL)¶
Leverage robust, pre-built utilities and design generic, reusable systems. - Templates — Introduction to generic programming, template specialization, and compile-time logic. - Containers — Vectors, lists, maps, and unordered maps, along with their time complexities and layout semantics. - Algorithms — Built-in sorting, searching, mapping, and an introduction to ranges.
Part 4: Modern Evolution¶
Keep up with the modern features that make C++ one of the most powerful languages today.
- Modern Utilities — std::optional, std::variant, std::string_view, and std::span for clean, safe code.
- C++20 Features — Concepts, Ranges, Coroutines, and formatting upgrades.
- C++23 Features — std::print, std::expected, and multidimensional subscripts.
- Build Systems — Makefiles and modern target-based CMake project architecture.