Clase base tiene tipo incompletoClase base tiene error de tipo incompleto
¿Qué significa exactamente este error y cómo puedo solucionarlo? Intenté declarar la clase haciendo class Entity
en el encabezado de EntityPhysics, pero no funcionó.
Aquí es mi 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__) */
Y mi 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__) */
creo que puede tener que ver conmigo incluyendo Entity.h
en la clase de niño, pero si lo hago Me sale el mismo error.
no se puede declarar una clase hacia adelante y luego usar esa declaración hacia adelante para, por ejemplo, la herencia. Todo lo que puede hacer con un tipo declarado hacia adelante es declarar un puntero o referencia a dicho tipo. Además, no es que ambas clases contengan funciones virtuales puras y, como tal, no se puede crear una instancia de ninguna directamente. –
Además, no debería utilizar doble guión bajo en sus identificadores. Los identificadores que comienzan con un guion bajo doble están reservados para ser utilizados por el compilador. –
@EdS., Identificadores * que contienen * subrayados dobles están reservados ([Referencia] (http://stackoverflow.com/questions/228783/what-are-the-rules-about-using-an-underscore-in-ac- identificador)). Me llevó muchas veces leerlo antes de recibir ese mensaje por alguna razón. Además, al iniciar un identificador de alcance global con un guión bajo lo coloca en el mismo barco. – chris