Jump to content
  • Advertisement
Sign in to follow this  
FoxMulder900

[SOLVED] Linker error - static vector in singleton class

This topic is 3696 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

Hello, I am working on a basic event handler class, the class is a singleton and I have almost all the basics in place. When I compile I get the following linker error
error LNK2001: unresolved external symbol "private: static class std::vector<class EventListener *,class std::allocator<class EventListener *> > EventHandler::listeners" (?listeners@EventHandler@@0V?$vector@PAVEventListener@@V?$allocator@PAVEventListener@@@std@@@std@@A)
1>C:\Documents and Settings\Matt\Desktop\Ozzmosis3D\Debug\Ozzmosis3D.exe : fatal error LNK1120: 1 unresolved externals
Here is my code:
#include <SDL.h>
#include <vector>

#include "EventListener.h"

using namespace std;

class EventHandler
{
	static vector<EventListener*> listeners;
public:
	static EventHandler* Singleton();
	static void registerListener(EventListener* listener);
	static void handleEvents();
protected:
	EventHandler(){}
	EventHandler& operator= (const EventHandler&);

};
I am unsure of what is causing the error - I tried making the vector non-static however, since this is a singleton class I get more complaints elsewhere. A brief description of what I am trying to accomplish is as follows: I am trying to implement an event handler that stores a list of objects which inherit from my eventListener class. Then when the event handler gets an event, for example a key press, it will simply iterate through the list of listeners and call their appropriate keyPressed functions. Any help or suggestions would be much appreciated! [Edited by - FoxMulder900 on May 8, 2008 9:41:17 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!