Sign in to follow this  
Mizipzor

Unresolved externals

Recommended Posts

Im using something Ive learned from an article called "singleton pattern" so I can make sure only one instance of the class exists. I made the graphic class singleton, worked fine. But when I tried to do it on the font class it did not... Too me it looks like I made them identical. But apparently, I did not. I get this error:
Game.obj : error LNK2001: unresolved external symbol "protected: static class FontSystem * FontSystem::m_pInstance" (?m_pInstance@FontSystem@@1PAV1@A)

This is the class (cut down version)
#ifndef _FONT
#define _FONT

class FontSystem {
protected:
	// Singleton class
	static FontSystem* m_pInstance;
	FontSystem( void ) { };


public:
	// Singleton ---
	static FontSystem* GetInstance( void ) {
		if ( !m_pInstance )
			m_pInstance = new FontSystem();
		return m_pInstance;
	};
};

#endif

What am I doing wrong?

Share this post


Link to post
Share on other sites
You have declared but not defined your static variable. You need to add FontSystem* FontSystem::m_pInstance; to a (single!) source file.

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