I have
struct IMyInterface
{
virtual method1() = 0;
virtual method2() = 0;
};
GCC insists that I have
struct IMyInterface
{
virtual method1() = 0;
virtual method2() = 0;
virtual ~IMyInterface(){};
};
I dont see why. A pure interface is all about the interface (duh). The destructor is part of the internal implementation details of a concrete implementer of the interface; it does not form part of the interface. I understand the whole slicing issue (or at least I think I do)
So my question is - is GCC right to insist on it and if so why?
virtual ~IMyInterface() = 0;
) but if the linker complains about a missing definition, you can actually still provide implementations for pure virtual functions, ie.virtual ~IMyInterface() = 0 {}
. – Rail