private constructor rejected by visua studio? why

hi

Im trying to create a singleton but visual studio is rejecting my private constructor.
Why is this? aren't singleton constructors meant to be private or is it that they are shunned by visual studio?

1
2
3
4
5
6
7
8
9
10
class CStart_Menu :
	public CStates<CGAME_MANAGER>
{
private:

	CStart_Menu();

public:
	//BEGIN STATE:
	 virtual FAST_BOOL Enter(CGAME_MANAGER* qp_laststate)


1>Start_Menu.obj : error LNK2019: unresolved external symbol "private: __thiscall
 CStart_Menu::CStart_Menu(void)" (??0CStart_Menu@@AAE@XZ) referenced in function 
"public: static class CStart_Menu * __cdecl CStart_Menu::Instance(void)" (?
Instance@CStart_Menu@@SAPAV1@XZ)

1>Start_Menu.obj : error LNK2019: unresolved external symbol "public: virtual __thiscall 
CStates<class CGAME_MANAGER>::~CStates<class CGAME_MANAGER>(void)" (??1?
$CStates@VCGAME_MANAGER@@@@UAE@XZ) referenced in function "public: virtual __thiscall 
CStart_Menu::~CStart_Menu(void)" (??1CStart_Menu@@UAE@XZ)

1>c:\users\portsmouthuni\documents\visual studio 
2010\Projects\consolegamestate\Debug\consolegamestate.exe : fatal error LNK1120: 2 
unresolved externals

========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited on
It isn't rejecting the constructor, having a private constructor is perfectly legal and necessary for a singleton object, the error is that you haven't given the constructor a definition.
thanks

but now its refusing my singleton definition in the header file whats the likely cause for it?
Hard to say without seeing the relevant code or error message.
Code below, I'm getting the suspect that it doesn't like my singleton declaration written below

1
2
3
4
5
6
7
8
//...
//.....this is the bottom of the class header file
	virtual ~CStart_Menu(void);
};

#define stSTART_MENU CStart_Menu::Instance()

#endif 

1>c:\users\portsmouthuni\documents\visual studio 2010\projects\consolegamestate\consolegamestate\main.cpp(8): error C2352: 'CStart_Menu::Instance' : illegal call of non-static member function
1>          c:\users\portsmouthuni\documents\visual studio 2010\projects\consolegamestate\consolegamestate\start_menu.h(34) : see declaration of 'CStart_Menu::Instance'
The error is what it says. You are trying to call Instance as if it were a static function, but it isn't a static function.

It probably should be static.
Topic archived. No new replies allowed.