Base class undefined

若如初见. 提交于 2019-12-04 04:41:32
gztomas

If you have any source file that includes GameObjects.h before ProjectilObject.h or does not include ProjectilObject.h directly, then the compiler will first find the declaration of ProjectilObject through the include in GameObjects.h before knowing what WorldObject is. That is because GameObjects.h first includes ProjectilObject.h and then declares WorldObject. In that case the include of GameObjects.h present in ProjectilObject.h won't work because _GAMEONJECTCODE_H_ will be already defined.

To avoid this, either be sure to include ProjectilObject.h instead of GameObjects.h in your source file, or use forward declarations.

It's hard to answer this question without looking at the whole code. Even a misplaced brace could count. Check your namespaces - are you sure the WorldObject is in the same namespace?

I suggest you use the #pragma message by placing it near the WorldObject definition and checking the compiler output:

#pragma message ("World object is defined")

If it does not show up, move the pragma to the parent .h file and check the compiler output again. With this you can easily locate the error.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!