As long as I don't call the function, everything is fine, but once I call the function I get an unresolved external symbol. All of my classes are in the SSE namespace (my own) and have worked fine up until now. Let me show.
#include "SDL.h"
#include "Game.h"
#include "GameObject.h"
#include <tchar.h>
SSE::Game Pong;
int _tmain(int argc, char* argv[])
{
SSE::GameObject* object;
Pong.Initialize("Pong!");
object = Pong.Objects().ObjectCreate<SSE::GameObject>();
while (!Pong.bQuit)
{
Pong.Update();
Pong.Draw();
}
return 0;
}
This is where I call the function. Game is a class that runs the behind the scenes work for me (everything's fine with that class), Game.Objects() returns the Game's ObjectManager which is in charge of creating and deleting objects as well as giving objects their components. ObjectCreate is a template function which returns a pointer to the new object created.
From the ObjectManager's .cpp file:
template <class G>G* ObjectManager::ObjectCreate()
{
ObjectList* tempObjList;
tempObjList = new tempObjList();
tempObjList->objectType = G->ClassName();
tempObjList->objectTypeNumber = 0;
for (unsigned int i = 0; i < v_objList.size(); i++;)
{
if (v_objList[i]->objectType == tempObjList->objectType)
tempObjList->objectTypeNumber++;
}
tempObjList->gameObject = new G(tempObjList->objectType + "_" + tempObjList->objectTypeNumber);
v_objList.push_back(tempObjList);
if (v_objList.back() != tempObjList)
{
delete tempObjList;
return NULL;
}
return v_objList.back();
}
This assigns a unique name for the new GameObject and creates it in memory, then stores it into a vector. One other thing to mention is I've been getting this unresolved external symbol error for many of the ObjectManager and GameObject functions similar to this one, but just the same only if I call them in code.
Just for reference, the error is: Error 2 error LNK2019: unresolved external symbol "public: class SSE::GameObject * __thiscall SSE::ObjectManager::ObjectCreate(void)" (??$ObjectCreate@VGameObject@SSE@@@ObjectManager@SSE@@QAEPAVGameObject@1@XZ) referenced in function _SDL_main C:\SDL\SimpleStateEngine\SSE\main.obj SSE
Let me know if you need anything else, I've been searching for hours.