Skip to content
BoKSA

C++ for Embedded Fundamentals

C++ for Embedded Fundamentals

Use this page to revise a subset of C++ that is common in firmware — not the whole standard library.

What you keep from C

Same compilation model, same registers, same need for volatile and fixed-width types. C++ adds types and encapsulation, not a garbage collector.

Classes, RAII, references

A class bundles data and functions. RAII ties resource lifetime to an object destructor (lock, peripheral handle). A reference is an alias, not a reseatable pointer. const on methods documents mutation.

What to avoid on small MCUs

Exceptions, heavy RTTI, default iostream, unbounded templates that explode flash, and frequent new. An embedded subset (often "C with classes" plus templates used carefully) is a deliberate choice.

Starting Points

Key Points

  • You can explain what a class and a constructor/destructor are for in firmware.
  • You can explain RAII in one example (e.g. a lock or a mapped buffer).
  • You can contrast a reference with a pointer.
  • You can name C++ features you would disable or avoid on a small MCU and why.
  • You can explain why "Arduino C++" and "bare-metal C++" are not the same as desktop C++.