This specific case is for Arduino, but the question applies in general. The SDK provides a Client
class, from which other classes (WiFiClient
, EthernetClient
, and others) derive.
In my own class I have a field of type Client*
which can hold any of those derived classes. I'd like to be able to delete clientfield
in my class (specifically in its destructor), but because Client
does not provide a virtual destructor, that would cause undefined behaviour.
Any suggestions for ways to work around this?
I could Modify Client
to add the destructor, but that's not ideal since anyone using my code would have to make that same change on their system.