I know that this is probably a stupid question :\ but I am stupid...
I am getting 1>angledCollision.obj : error LNK2001: unresolved external symbol "protected: static class angledCollision * Singleton<class angledCollision>::ms_Singleton" (?ms_Singleton@?$Singleton@VangledCollision@@@@1PAVangledCollision@@A)
1>spawningArea.obj : error LNK2001: unresolved external symbol "protected: static class angledCollision * Singleton<class angledCollision>::ms_Singleton" (?ms_Singleton@?$Singleton@VangledCollision@@@@1PAVangledCollision@@A)
I know the problem is that a source file wasn't found, but I can't see where...
Singleton hedder(theres no .cpp implementation):
#ifdef _MSVC
// Turn off warnings generated by this singleton implementation
#pragma warning (disable : 4311)
#pragma warning (disable : 4312)
#endif
#ifndef SINGLETON_H
#define SINGLETON_H
#include <assert.h>
template <typename T> class Singleton
{
protected:
static T* ms_Singleton;
public:
Singleton()
{
assert( !ms_Singleton );
int offset = (int)(T*)1 - (int)(Singleton <T>*)(T*)1;
ms_Singleton = (T*)((int)this + offset);
}
~Singleton(){ assert( ms_Singleton ); ms_Singleton = 0; }
static T* getSingleton() { return ms_Singleton; }
};
#endif
here is where I declared that angledCollision is a child of singleton
class angledCollision : public Singleton<angledCollision>
and finally, here are my #include's for both linking error files:
angledCollision:
#include <vector>
#include <math.h>
#include <glut.h>
#include "aCNode.h"
#include "Singleton.h"
spawningArea:
#include <math.h>
#include <iostream>
#include "render.h"
#include "loadTex.h"
#include <gl/glut.h>
#include "TextureLoader.h"
#include "Vector3D.h"
...
class spawningArea : public render // thus ill also show you render's #include's
render:
#include "texturedPolygons.h"
#include "angledCollision.h"
I did try #include'ing "angledCollision.h" inside of spawningArea, it changed nothing
so why am I still getting linking errors? if you need any more source just ask, decided not to dump everything because I don't think the internet is big enough :P
btw, If you see my history, I haven't answered any questions, Ive been trying to answer un-solved questions, but my solutions are always overly complex and may be hard to understand, so I don't bother, so I am trying to help the comunity, not just leach.
###EDIT###
oh, btw, before I make anything using angledCollision, i have spcified:
//initiates angledCollision singleton
new angledCollision;