We're building an application in c++ on Linux. We began with the
Xerces-C 1.0.1 release, but recently switched to the most recent CVS
version.
On both versions, we are getting warnings from the compiler when we
turn on strict warnings:
g++ -Wall -O -g -c Rule.cpp -o Rule.o
In file included from /usr/local/include/dom/DOM_NodeIterator.hpp:70,
from /usr/local/include/dom/DOM_Document.hpp:98,
from /usr/local/include/dom/DOM.hpp:80,
from RuleTree.h:10,
from Rule.cpp:6:
/usr/local/include/dom/DOM_NodeFilter.hpp:108: warning: `class
DOM_NodeFilter' has virtual functions but non-virtual destructor
In file included from /usr/local/include/dom/DOM_Document.hpp:98,
from /usr/local/include/dom/DOM.hpp:80,
from RuleTree.h:10,
from Rule.cpp:6:
/usr/local/include/dom/DOM_NodeIterator.hpp:114: warning: `class
DOM_NodeIterator' has virtual functions but non-virtual destructor
In file included from /usr/local/include/dom/DOM_Document.hpp:99,
from /usr/local/include/dom/DOM.hpp:80,
from RuleTree.h:10,
from Rule.cpp:6:
/usr/local/include/dom/DOM_TreeWalker.hpp:121: warning: `class
DOM_TreeWalker' has virtual functions but non-virtual destructor
As I understand C++, the risk with the non-virtual destructor is that
if you derive from the class and add data members, they may not get
destroyed properly.
I can't find any places in the Xerces source where any of these are
subclassed. Do they need to have virtual methods?
If they can be subclassed, the destructors should be defined virtual;
otherwise, the methods should be changed to non-virtual.
- irving -