Jump to content
  • Advertisement
Sign in to follow this  
grekster

LNK2019 Error: Probably a template problem:S

This topic is 4828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!