2012-10-01 20 views
6

बेस वर्ग अधूरा प्रकार हैबेस वर्ग अधूरा प्रकार की त्रुटि है

वास्तव में इस त्रुटि का क्या मतलब है और मैं इसे कैसे ठीक कर सकते हैं? मैंने अपने EntityPhysics शीर्षलेख में class Entity करके कक्षा घोषित करने की कोशिश की है लेकिन यह काम नहीं किया है।

यहाँ मेरी Entity.h

#ifndef __Game__Entity__ 
#define __Game__Entity__ 

#include <iostream> 
#include <string> 

#include "OGRE/Ogre.h" 

#include "OgreInit.h" 

class Entity{ 
public: 
    Entity(std::string entityId, std::string mesh, Ogre::Vector3 position = Ogre::Vector3::ZERO, Ogre::Vector3 rotation = Ogre::Vector3::ZERO); 
    virtual ~Entity() = 0; 

    void setPosition(Ogre::Vector3 position); 
    Ogre::Vector3 getPosition(); 
    void setRotation(Ogre::Vector3 rotationIncrease); 
    Ogre::Vector3 getRotation(); 
    void setMesh(std::string meshName); 
    std::string getMesh(); 
    virtual void tick() = 0; 
    void removeEntity(); 

    Ogre::Entity getEntity(); 
    Ogre::SceneNode getSceneNode(); 

    std::string entityId; 
protected: 
    Ogre::Entity *ent; 
    Ogre::SceneNode *nod; 
}; 

#endif /* defined(__Game__Entity__) */ 

और मेरे EntityPhysics.h

#ifndef __Game__EntityPhysics__ 
#define __Game__EntityPhysics__ 

#include <iostream> 
#include <string> 
#include "OGRE/Ogre.h" 
#include "OgreBulletCollisionsBoxShape.h" 
#include "OgreBulletDynamicsRigidBody.h" 

#include "Entity.h" 
#include "OgreInit.h" 

class EntityPhysics: public Entity //error occurs here: "Base class has incomplete type" 
{ 
public: 
    EntityPhysics(std::string pentityId, std::string mesh, Ogre::Vector3 position, Ogre::Vector3 rotation, /*Physics Specific "stuff"*/std::string shapeForm = "BoxShape", float friction = 1.0, float restitution = 0.0, float mass = 1.0); 
    virtual ~EntityPhysics() = 0; 
    virtual void tick() = 0; 
private: 
    float friction, restitution, mass; 

    OgreBulletCollisions::CollisionShape *collisionShape; 
    OgreBulletDynamics::RigidBody *rigidBody; 
}; 

#endif /* defined(__Game__EntityPhysics__) */ 

मुझे लगता है कि यह मेरे बच्चे को कक्षा में Entity.h सहित के साथ क्या करना है, लेकिन अगर मैं ऐसा मुझे समान त्रुटि मिली।

+0

आप एक कक्षा घोषित नहीं कर सकते हैं और फिर, कहने, विरासत के लिए आगे की घोषणा का उपयोग नहीं कर सकते हैं। आप अग्रेषित घोषित प्रकार के साथ क्या कर सकते हैं एक संकेतक या कहा प्रकार के संदर्भ घोषित करना है। यह भी नहीं कि इन दोनों वर्गों में शुद्ध वर्चुअल फ़ंक्शंस हैं और, इस तरह, आप सीधे या तो एक उदाहरण नहीं बना सकते हैं। –

+1

इसके अलावा, आपको अपने पहचानकर्ताओं में डबल अंडरस्कोर का उपयोग नहीं करना चाहिए। डबल अंडरस्कोर से शुरू होने वाले पहचानकर्ता संकलक द्वारा उपयोग के लिए आरक्षित हैं। –

+0

@ एडीएस।, पहचानकर्ता * युक्त * डबल अंडरस्कोर आरक्षित हैं ([संदर्भ] (http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-ac- पहचानकर्ता))। कुछ कारणों से मुझे यह संदेश मिलने से पहले मुझे इसे कई बार पढ़ना पड़ा। इसके अलावा, एक अंडरस्कोर के साथ एक वैश्विक स्कोप पहचानकर्ता शुरू करना इसे एक ही नाव में रखता है। – chris

उत्तर

7

यह सर्कुलर के कारण सबसे अधिक संभावना है, और इसे ठीक करने का तरीका उन निकायों को निकालना है जहां आपको उनकी आवश्यकता नहीं है।

Entity.h में आप की जरूरत नहीं है:

#include "OGRE/Ogre.h" 
#include "OgreInit.h" 

आप कर सकते हैं, और चाहिए, बजाय प्रकार आगे की घोषणा करते हैं। EntityPhysics.h के लिए एक ही और:

#include "OGRE/Ogre.h" 
#include "OgreBulletCollisionsBoxShape.h" 
#include "OgreBulletDynamicsRigidBody.h" 

#include "OgreInit.h" 

केवल एक ही आप वास्तव में जरूरत है Entity.h है।

+0

मुझे सीपीपी फ़ाइल में कुछ अन्य वर्गों की आवश्यकता है जो इसके साथ चलती हैं। – Nik

+0

ऐसा लगता है कि 'Entge.hit.h' अभी भी 'Entity.h' में आवश्यक है, क्योंकि' Ogre :: Vector3 :: ZERO' को परिभाषित किया गया है। – Rost

+0

@ cot फ़ाइलों में notrodash अन्य फ़ाइलों को शामिल कर सकते हैं, यह ठीक है। –

0

मेरे पास एक समान त्रुटि संदेश था जिसे मैंने हेडर फ़ाइल को नीचे दिए गए # शामिल करने के द्वारा हल किया था ताकि वर्ग परिभाषा और विधि परिभाषा जो कि अन्य # शामिल इच्छा अन्य हेडर की तुलना में पहले आती है।

संबंधित मुद्दे