나는 singalton 클래스 예제를 사용하고 있습니다.링커 오류 받기
error LNK2001: unresolved external symbol "public: static class CConfig * CConfig::config" ([email protected]@@[email protected])
SingaltonClass.exe : fatal error LNK1120: 1 unresolved externals
:
#include "stdafx.h"
#include "SingaltonClass.h"
void hello();
CConfig*
CConfig :: initilize_config()
{
if (config == 0)
{
config = new CConfig();
}
return config;
}
int _tmain(int argc, _TCHAR* argv[])
{
CConfig *cconfig = CConfig::initilize_config();
cconfig->displayStatus();
hello();
return 0;
}
void hello()
{
CConfig *config = CConfig::initilize_config();
config->displayStatus();
}
내가 점점 오전 오류 다음 비주얼 스튜디오 10에서 컴파일에 .. 여기 은 .H 파일
#ifndef __SINGALTON_CLASS__
#define __SINGALTON_CLASS__
#include "iostream"
class CConfig
{
private:
CConfig(){};
private:
bool status;
static CConfig* config;
public:
static CConfig* initilize_config();
~CConfig()
{
}
void displayStatus()
{
std::cout << "Status:"<<status;
}
};
#endif //__SINGALTON_CLASS__
이며, 여기에 .cpp 파일의 코드는 나는 정확히 어디서 문제인지 이해할 수 없다. 답장을 부탁한다.
나는 그 변수를 초기화하지만 여전히 내가 같은 오류가 무엇입니까 .. 작동합니다. –
@RavindraGupta 새 코드로 질문을 업데이트하십시오. 귀하의 질문에 여전히 정의가없는 소스 코드가 있습니다. – manuell