Archived

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

TheGecko

Why is this error happening?

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