Which is something I really don’t understand: I see nothing which actually makes this error prone.
Here’s the class:
namespace Engine_Main {
class SceneManager
{
public:
SceneManager(Engine& engine);
void createScene();
private:
Ogre::SceneManager * mSceneMgr;
};
}
Along with a few other classes for reference:
#ifndef ENGINE_H
#define ENGINE_H
#include <OGRE/OgreSceneManager.h>
#include <OGRE/OgreRoot.h>
#include "scenemanager.h"
#include "playerinput.h"
namespace Engine_Main {
class Engine
{
public:
Engine();
~Engine();
void initGameLoop();
PlayerInput * getPlayerInput();
PlayerMovement * getPlayerMovement();
Ogre::Root * getOgreRoot();
private:
//fields
PlayerInput * mPInput;
PlayerMovement * mPMovement;
Ogre::Root * mRoot;
//methods
void registerInput();
void createScene();
void renderPosition();
};
}
#endif // ENGINE_H
#include "engine.h"
namespace Engine_Main {
/**********/
/* PUBLIC */
/**********/
PlayerMovement * Engine::getPlayerMovement() {
return mPMovement;
}
PlayerInput * Engine::getPlayerInput() {
return mPInput;
}
Engine::Engine() {
mPInput = new PlayerInput();
mPMovement = new PlayerMovement();
mRoot = new Ogre::Root("cfg/plugins.cfg", "cfg/engine.cfg", "cfg/engine.log");
}
Engine::~Engine(){
if (mPInput) {
delete mPInput;
}
if (mRoot) {
delete mRoot;
}
}
void Engine::createScene() {
}
}
My question
What is it that I’m doing wrong?
Are you missing a (forward) declaration of
Enginein"scenemanager.h"? When the compiler parses:it needs a declaration of the
Enginetype. You may need a forward declaration likeclass Engine;before the declaration of theSceneManagerclass.