LNK2019 Error: Probably a template problem:S

Started by
3 comments, last by grekster 18 years, 7 months ago
While working on my event manager ive encountered a linker error and i think it could be a problem with my templates (not sure though). At the moment I have: MDWEvents.h

class cEventManager
{
private:

public:

	template<class T>
	void RegisterListener(char* EventName, T* pClass, void (T::*func)(cEvent&) );
};

MDWEvents.cpp

template<class T>
void cEventManager::RegisterListener(char* EventName, T* pClass, void (T::*func)(cEvent&))
{
	int ID = this->RegisterEventType(EventName);
	cSignal1<cEvent>* sig = this->Events[ID];
	sig->connect(pClass,func);
}

All the other functions that ive defined link ok so im not sure on the problem. If anyone has any ideas (or even better a solution:) )id love to hear them.
Quote:Original post by BosskIn Soviet Russia, you STFU WITH THOSE LAME JOKES!
Advertisement
What's the exact error message?
damn, how did i forget that lol

JABRECLO error LNK2019: unresolved external symbol "public: void __thiscall cEventManager::RegisterListener<class cGame>(char *,class cGame *,void (__thiscall cGame::*)(class cEvent &))" (??$RegisterListener@VcGame@@@cEventManager@@QAEXPADPAVcGame@@P81@AEXAAVcEvent@@@Z@Z) referenced in function "public: __thiscall cGame::cGame(void)" (??0cGame@@QAE@XZ)

and the function call is

this->Events.RegisterListener("START_SHINE",this,&cGame::AnimationEvent);
Quote:Original post by BosskIn Soviet Russia, you STFU WITH THOSE LAME JOKES!
Template functions need to be defined in the header file. Otherwise, how would the compiler know how to specialize the function? Move RegisterListener to MDWEvents.h.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
Great thats fixed it, knew it was a template problem been ages since i last used them.

Thanks a lot JohnBolton
Quote:Original post by BosskIn Soviet Russia, you STFU WITH THOSE LAME JOKES!

This topic is closed to new replies.

Advertisement