The type in dynamic_cast must be a pointer or reference to the full type of the class or void *

I hope there is someone who understands why the code below fails. I am trying to get an instance of the PositionAttitudeTransform class (Openscenegraph class) from an osg :: Node * node object. But there is a compiler error in bold.

void CameraPosCallbackUpdate::operator()(osg::Node* node, osg::NodeVisitor* nv) { // other code goes here osg::PositionAttitudeTransform* pat = dynamic_cast<osg::PositionAttitudeTransform*> (node); } 

IntelliSense: the type in dynamic_cast must be a pointer or a reference to the full type of the class or void *

Please help me with the correct way to access my object, and I would appreciate help in understanding that the problem is here, since I believe that casting should be possible.

Hierarchy http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00529.html

+4
source share
1 answer

I believe that you should #include header file containing the body of the class osg::PositionAttitudeTransform .
dynamic_cast gives this error when the body of the target class is not visible.

Here is a similar error reproduced in g ++ .

+7
source

Source: https://habr.com/ru/post/1442912/


All Articles