On 24/08/2015 at 04:56, xxxxxxxx wrote:
Originally posted by xxxxxxxx
Hi,thanks for the answer first of all.I know why a virtual destructor is used in a (base) class, thanks, still the question remains, why is it made an error instead of keeping it a warning (actually compiler-wise this is even off by default)? It would surely be enough for an implementer to be notified (via the appropriate warning) instead of throwing a compiler error globally which collides with other class concepts (for example when by design it shall not be destroyed by deleting a base class pointer).
As explained, in the context of the SDK it's almost certain that you have a resource leak/bug if you don't have a virtual destructor - and we found plenty of plugins where exactly that happened (and programmers just ignored the warning).
It's possible to create classes (with virtual methods) where a virtual destructor ain't necessary, but you have been very cautious and as shown in the link Sebastian pointed too, even then you might run into problems you haven't thought of.
You can of course change this compiler message from an error to a warning, personally I'd chose a different class design though.
Best regards,
Wilfried