Explores implementing C#-style static classes in C++ for embedded systems by deleting the default constructor to prevent instantiation. Shows how to combine static classes with C++20 concepts and templates to create platform-independent firmware business logic — using a PowerManager concept as a concrete example with an STM32-specific implementation. Also covers testability challenges of static state and demonstrates a mock wrapper pattern for unit testing code that depends on static classes.

5m read timeFrom embeddedrelated.com
Post cover image
Table of contents
Static class in C++TestabilityConclusion
1 Impression