   Why am I getting linker errors here?
  I'm writing a simple event handling system (yes, I know I'm reinventing the wheel here, but it's largely a learning exercise), and am getting unresolved externals for reasons which escape me at the moment (using MSVS 2005 EE).Relevant code (yes, I know this is non standard, hacky, and probably doesn't even works as it is now):Event.h#ifndef EVENT_H#define EVENT_H#include <hash_map>#include <queue>#include <string>#include "Types.h"namespace ISO{namespace Base{class Delegate;typedef void (Delegate::*Function)(void);class Event{public:Event() {}Event(Delegate *del, Function func) : d(del), f(func) {}void Dispatch() { (d->*f)(); }private:Function f;Delegate *d;};class EventManager{public:EventManager();~EventManager();template <class C>void RegisterEventHandler(std::string id, C* handlerClass, void (C::*handler)(void));void CreateEvent(std::string id);void DispatchEvents();std::queue< Event > EventQueue;private:stdext::hash_map<std::string, Event > m_HandlerMap;};}}#endifEvent.cpp#include <cassert>#include "../Header Files/Event.h"ISO::Base::EventManager::EventManager(){}ISO::Base::EventManager::~EventManager(){}template <class C>void ISO::Base::EventManager::RegisterEventHandler(std::string id, C* delegateClass, void (C::*handler)(void)){m_HandlerMap[id] = Event(static_cast<Delegate*>(delegateClass), static_cast<Function>(handler));}void ISO::Base::EventManager::CreateEvent(std::string id){assert( m_HandlerMap.find(id) != m_HandlerMap.end() );EventQueue.push( m_HandlerMap[id] );}void ISO::Base::EventManager::DispatchEvents(){while (!EventQueue.empty()){EventQueue.front().Dispatch();EventQueue.pop();}}WinMain.cpp#include <Windows.h>//have to hack this together because WM_MOUSEWHEEL is not in winuser.h#define WM_MOUSEWHEEL   0x020A#include <string>#include "../../Graphics/Header Files/Renderer.h"#include "../Header Files/Event.h"ISO::Base::EventManager *g_Events;int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/,LPSTR /*CommandLine*/, int nCmdShow ){...  ISO::Graphics::Renderer renderer(wnd.GetHWND());g_Events->RegisterEventHandler<ISO::Graphics::Renderer>("draw", &renderer, &ISO::Graphics::Renderer::Render);...while ( wnd.HandleMessages() ){g_Events->CreateEvent("draw"); //create a draw eventg_Events->DispatchEvents(); //and dispatch itSleep(0);}return EXIT_SUCCESS;}And the errors:1>Compiling...1>Event.cpp1>WinMain.cpp1>Generating Code...1>Skipping... (no relevant changes detected)1>Renderer.cpp1>Linking...1>WinMain.obj : error LNK2019: unresolved external symbol "public: void __thiscall ISO::Base::EventManager::CreateEventA(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?CreateEventA@EventManager@Base@ISO@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _WinMain@161>WinMain.obj : error LNK2019: unresolved external symbol "public: void __thiscall ISO::Base::EventManager::RegisterEventHandler<class ISO::Graphics::Renderer>(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >,class ISO::Graphics::Renderer *,void (__thiscall ISO::Graphics::Renderer::*)(void))" (??$RegisterEventHandler@VRenderer@Graphics@ISO@@@EventManager@Base@ISO@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@PAVRenderer@Graphics@2@P8562@AEXXZ@Z) referenced in function _WinMain@161>C:\Users\Chuck\Documents\YAGE\Debug\YAGE.exe : fatal error LNK1120: 2 unresolved externalsThanks!   
  CreateEvent is a macro defined in windef.h or something like that.;1>WinMain.obj : error LNK2019: unresolved external symbol "public: void __thiscall ISO::Base::EventManager::CreateEventA(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >)" (?CreateEventA@EventManager@Base@ISO@@QAEXV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@@Z) referenced in function _WinMain@16Is caused because somewhere in the windows headers they have macros that #define CreateEvent to either CreateEventA or CreateEventW depending on if you are doing an Ascii or Unicode build.Alan   ;  Also, you need to put template function definitions in the header file. Otherwise, when the compiler is compiling WinMain.cpp, how is it supposed to know how to create the body of RegisterEventHandler<ISO::Graphics::Renderer>?   ;  Thanks to both of you. I've got it compiling now, at least.Quote:Original post by JohnBoltonAlso, you need to put template function definitions in the header file. Otherwise, when the compiler is compiling WinMain.cpp, how is it supposed to know how to create the body of RegisterEventHandler<ISO::Graphics::Renderer>?Right, I always forget about that.   