Firstly, some sauce:
(mmmmm sauce)
class Render
{
friend static class RenderManager;
protected:
static RenderManager* m_pTheBoss;
static MyDrawEngine* m_pTheDrawEngine;
public:
Render(void);
}
Render::Render(void)
{
Render::m_pTheBoss->Register(this);
}
class RenderManager
{
public:
MyDrawEngine* m_pTheDrawEngine;
public:
RenderManager();
}
//Constructor for RenderManager
RenderManager::RenderManager()
{
//Create a new drawing engine
m_pTheDrawEngine = new MyDrawEngine();
//Make sure the renderables know who the daddy is
Render::m_pTheBoss = this;
Render::m_pTheDrawEngine = this->m_pTheDrawEngine;
}
I can not for the life of me see why I get the following linker errors:
Render.obj : error LNK2001: unresolved external symbol "protected: static class RenderManager * Render::m_pTheBoss"
(?m_pTheBoss@Render@@1PAVRenderManager@@A)
Render.obj : error LNK2001: unresolved external symbol "protected: static class MyDrawEngine * Render::m_pTheDrawEngine"
(?m_pTheDrawEngine@Render@@1PAVMyDrawEngine@@A)
Debug/spac0r.exe : fatal error LNK1120: 2 unresolved externals
commenting out the two lines that reference the static variables of Render from RenderManager() leaves me with the top error. commenting out the line in Render() constructor that references the static variable removes the top error (though the error remains if the reference to the variable is still there in RenderManager())
ARGH!
I can't see what I'm doing wrong. Even if it was a problem with friend, I shouldn't get an error from the Render() constructor, should I?