簡體   English   中英

嘗試訪問“常量類LHContactInfo”時的前向聲明錯誤

[英]forward declaration of 'const class LHContactInfo' error when try to access it property

我有兩個下面的C ++類。 我想從LHSceneSubclass獲取LHContactInfo屬性,但是我什么也得不到。那么我該怎么辦?

 #ifndef __LEVELHELPER_API_CONTACT_INFO_H__ #define __LEVELHELPER_API_CONTACT_INFO_H__ #include "LHConfig.h" #if LH_USE_BOX2D #include "cocos2d.h" class b2Contact; using namespace cocos2d; class LHContactInfo { public: LHContactInfo(); virtual ~LHContactInfo(); Node* nodeA; Node* nodeB; std::string nodeAShapeName; std::string nodeBShapeName; int nodeAShapeID; int nodeBShapeID; Point contactPoint; float impulse; b2Contact* box2dContact; }; #endif #endif //__LEVELHELPER_API_CONTACT_INFO_H__ #include "LHContactInfo.h" #if LH_USE_BOX2D #include "Box2d/Box2d.h" LHContactInfo::LHContactInfo(){ nodeA = NULL; nodeB = NULL; box2dContact = NULL; } LHContactInfo::~LHContactInfo(){ nodeA = NULL; nodeB = NULL; box2dContact = NULL; } #endif 

 #ifndef __LH_SCENE_SUBCLASS_H__ #define __LH_SCENE_SUBCLASS_H__ #include "cocos2d.h" #include "LevelHelper2API.h" class LHContactInfo; class LHSceneSubclass : public LHScene { public: static cocos2d::Scene* createScene(); LHSceneSubclass(); virtual ~LHSceneSubclass(); bool initWithContentOfFile(const std::string& plistLevelFile); virtual bool shouldDisableContactBetweenNodes(Node* nodeA, Node* nodeB); virtual void didBeginContact(const LHContactInfo& contact); virtual void didEndContact(const LHContactInfo& contact); }; #endif // __LH_SCENE_SUBCLASS_H__ //file.cpp void LHSceneSubclass::didBeginContact(const LHContactInfo& contact){ if(contact.nodeA->getName() == "box1"){// error invalid use of incomplete type 'const class LHContactInfo' } } void LHSceneSubclass::didEndContact(const LHContactInfo& contact){ CCLOG("DIDENDCONTACT...\\n"); } 

我想在didBeginContact函數中像LHContactInfo的contact.nodeA一樣,但是編譯錯誤->錯誤使用不完整類型'const class LHContactInfo'

注意::-使用android NDK 10c進行編譯

由於您的前向聲明,僅聲明了LHContactInfo類(即,按名稱知道)。 但是,編譯器需要類定義。 您需要包括包含類定義的文件。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM