#ifndef SC_H
#define SC_H
class SC
{
public:
~SC();
static SC* Get();
int GetNumber();
void SetNumber(int n);
protected:
SC();
static SC* s_Instance;
int m_Number;
};
//====================================================================================================
// Global Functions
//====================================================================================================
static SC* SCL( void )
{
return SC::Get();
}
;
#endif
// .cpp file
#include "stdafx.h"
#include "SingletonClass.h"
SC::~SC()
{
s_Instance = 0;
};
SC* SC::Get()
{
if (s_Instance == 0)
{
s_Instance = new SC();
}
return s_Instance;
};
int SC::GetNumber()
{
return m_Number;
};
void SC::SetNumber(int n)
{
m_Number = n;
};
SC::SC(): m_Number(0)
{s_Instance = 0;};
//errors:
Error 1 error LNK2020: unresolved token (0A00000F) "protected: static class SC * SC::s_Instance" (?s_Instance@SC@@1PAV1@A) SingletonClass.obj
Error 2 error LNK2001: unresolved external symbol "protected: static class SC * SC::s_Instance" (?s_Instance@SC@@1PAV1@A) SingletonClass.obj
How to solve this problem and where is wrong?