When an interface contains a pure virtual method, it is recommended to use a virtual destructor. So for example, I have this code:
template class A { protected: char buffer[Size]; public: virtual void method() = 0; A() = default; virtual ~A() = default; }; template class B : public A { public: void method() override; B() = default ~B() = default; }; int main() { B b; b.method(); }
But when I try to compile this with g++ for an Arduino Due, I get the following error:
main.cpp:(.text._ZN4r2d29robot_arm22uarm_gcode_generator_cILj100EED0Ev[_ZN4r2d29robot_arm22uarm_gcode_generator_cILj100EED5Ev]+0x6): undefined reference to `operator delete(void*, unsigned int)'
However, when I remove the destructor from A entirely, it removes the error, but wouldn't this cause Undifed Behaviour? Also, when I just remove the virtual keyword from the destructor of A it gives me the same error message.