From 855e1a6f251fcc78501a475e6bc7401d201d991e Mon Sep 17 00:00:00 2001 From: David Brown Date: Tue, 14 Jan 2025 09:19:29 +0100 Subject: [PATCH] Use virtual destructor in polymorphic base classes In order to be able to use classes such as `isobus::CANHardwarePlugin` polymophically C++ requires a `virtual` destructor in the base class. This ensures that, when the pointer to base is destroyed, that it will correctly call the derived destructors as well. --- .../include/isobus/hardware_integration/can_hardware_plugin.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hardware_integration/include/isobus/hardware_integration/can_hardware_plugin.hpp b/hardware_integration/include/isobus/hardware_integration/can_hardware_plugin.hpp index b42274e8..717cff4d 100644 --- a/hardware_integration/include/isobus/hardware_integration/can_hardware_plugin.hpp +++ b/hardware_integration/include/isobus/hardware_integration/can_hardware_plugin.hpp @@ -21,6 +21,8 @@ namespace isobus class CANHardwarePlugin { public: + virtual ~CANHardwarePlugin() = default; + /// @brief Returns if the driver is ready and in a good state /// @details This should return `false` until `open` is called, and after `close` is called, or /// if anything happens that causes the driver to be invalid, like the hardware is disconnected.