Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

TheGecko

Why is this error happening?

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

Hey people... I''m trying to implement a texture manager class (which is really a singleton class) and I''m getting the following error when I try to compile it: "error C2352: ''CTextureMng::GetManager'' : illegal call of non-static member function" Here''s the code to my texture manager class:
  
class CTextureMng
{
public:
	CTextureMng();
	virtual ~CTextureMng();

	CTextureMng *GetManager(void)
	{
		if(m_pSingleton)
		{
			CRef = 1;
			return(m_pSingleton);
		}
		else
		{
			CRef++;
			m_pSingleton = new CTextureMng;
			return(m_pSingleton);
		}
	}

	void ReleaseManager(void)
	{
		CRef--;
		if(CRef==0)
			delete m_pSingleton;
	}

private:
	static						CTextureMng *m_pSingleton;

	UINT						CRef;

	CEnigList<CEnigTexture>		m_TexList;
	
	LPCTSTR						m_sTexturePath;

};
  
And in my main program I''ve got this line of code:
  
//Get the singleton texture manager

m_TexMng = CTextureMng::GetManager();
  
Any ideas?

Share this post


Link to post
Share on other sites
Advertisement
Because you can''t call a member function when you haven''t got an object to call it on. You''ve defined GetManager() as a normal member function, when it should be a static member function. Same for ReleaseManager(), I assume.

Share this post


Link to post
Share on other sites
Yeah I tried that but then a whole slew of error cropped up. So I recoded my texture manager class and took another way out.It works fine now

Share this post


Link to post
Share on other sites

  • 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!