dynamic_cast中的类型必须是指向完整类类型的指针或引用,或者为void * [英] The type in a dynamic_cast must be a pointer or reference to a complete class type, or void *
问题描述
我希望外面有人能理解下面的代码为什么失败.我正在尝试从osg :: Node *节点对象获取PositionAttitudeTransform(Openscenegraph类)的实例.但是下面以粗体显示了编译器错误.
I am hoping there is someone out there who understands why the code below fails. I am trying to get an instance of PositionAttitudeTransform (Openscenegraph class) from an osg::Node* node object. But there is the compiler error below in bold.
void CameraPosCallbackUpdate::operator()(osg::Node* node, osg::NodeVisitor* nv)
{
// other code goes here
osg::PositionAttitudeTransform* pat = dynamic_cast<osg::PositionAttitudeTransform*> (node);
}
IntelliSense:dynamic_cast中的类型必须是指向完整类类型的指针或引用,或者为空*
请帮助我以正确的方式访问我的对象,希望能帮助我理解这里的问题,因为我相信强制转换是可能的.
Please help me with correct way to access my object and I would appreciate help in understanding what the problem here is since I believe the cast should be possible.
http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a00529.html
推荐答案
我相信您必须 #include
头文件,该头文件包含 class osg :: PositionAttitudeTransform
的正文>.
当目标类的正文不可见时, dynamic_cast
会给出此类错误.
I believe you have to #include
the header file which contains the body of class osg::PositionAttitudeTransform
.
dynamic_cast
gives such error when the body of the destination class is not visible.
以下是类似的在g ++中再现的错误.
这篇关于dynamic_cast中的类型必须是指向完整类类型的指针或引用,或者为void *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!