2.3 C++ for embedded
The C++ features that cost nothing on a microcontroller and the ones to avoid: classes and virtual calls, living without the heap and exceptions, RAII…
Lessons
- C++ classes and OOP for embedded · Classes, constructors, inheritance, virtual calls and what they cost.
- C++ embedded constraints and the STL · No heap, no exceptions, no RTTI: the C++ that fits a microcontroller.
- RAII and smart pointers · Tying resources to scope: lock guards, critical sections and unique_ptr.
- Templates and constexpr · Compile-time computation, type-safe registers and zero-cost abstractions.