2026-05-16 (3UE*2): Exercise Polymorphic Types#
Based on the demo in 2026-05-11 (3VO): C++: Inheritance (Mocking A Sensor), rearrange the
PMWPinside ofLogicin a way that:PWMPinconstitutes an interfaceThe original
PWMPinconcrete implementation is renamed toLinuxSysfsPWMPinLinuxSysfsPWMPinimplements thePWMPininterfaceLogicuses the interface,PWMPin
Modify
main.cppin a way that the “real” hardware implementationsLinuxSysfsPWMPinandLinuxHWMONSensorare not instantiated.Rather, instantiate
MockSensorandStdoutPWMPin, and pass these toLogic. When everything is well, you should see whatever you wrote in yourStdoutPWMPinimplementation.