[osg-users] No virtual destructor in osgAnimation::StackedRotateAxisElement. Why?

2011-07-25 Thread George Bekos
Hello everyone! :D

I have a simple question.
I want to inherit my class from osgAnimation::StackedRotateAxisElement but I 
realized that there is no virtual destructor in the class. Why? Because it is 
not needed because the class does not allocate anything from the heap? Or 
because it is a bad practice to inherit from this class? 
Thank you guys!

Cheers,
George

--
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=41620#41620





___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] No virtual destructor in osgAnimation::StackedRotateAxisElement. Why?

2011-07-25 Thread Jean-Sébastien Guay

Hello George,


I want to inherit my class from osgAnimation::StackedRotateAxisElement but I 
realized that there is no virtual destructor in the class. Why? Because it is 
not needed because the class does not allocate anything from the heap? Or 
because it is a bad practice to inherit from this class?


StackedRotateAxisElement itself has no virtual destructor (in fact, no 
destructor at all) probably because there was no need for one (no 
resources to free).


But in C++, if a class's base class (or its base class, right up to the 
root of that class's hierarchy) has a virtual destructor, it's assumed 
that all destructors of subclasses (even the default compiler-generated 
one that does nothing) are virtual. And since osg::Object has a virtual 
destructor (and StackedRotateAxisElement inherits indirectly from 
osg::Object) then it can be assumed that you can safely derive from 
StackedRotateAxisElement, and your subclass can have a virtual 
destructor, and it will be called when appropriate.


Hope this helps,

J-S
--
__
Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com
   http://www.cm-labs.com/
http://whitestar02.dyndns-web.com/
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org