Sign in to follow this  
grekster

LNK2019 Error: Probably a template problem:S

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this