I am currently working on a school project that uses the old VS2008 with essentially little to no error assistance. Anyways, I am trying to learn about Singeltons and was trying to create as basic as it goes. But suddenly from nowhere I am getting errors. Am I that blind or what am I doing wrong? Error:
1>.\Source\Singelton.cpp(3) : error C2065: 'NULL' : undeclared identifier
1>.\Source\Singelton.cpp(12) : error C2065: 'NULL' : undeclared identifier
1>.\Source\Singelton.cpp(21) : error C2065: 'NULL' : undeclared identifier
1>.\Source\Singelton.cpp(26) : error C2065: 'value' : undeclared identifier
1>.\Source\Singelton.cpp(30) : error C2065: 'value' : undeclared identifier
Complete code: header:
#ifndef __SINGELTON_H__
#define __SINGELTON_H__
class Singelton
{
private:
static Singelton* instance;
Singelton();
int value;
public:
~Singelton();
int get_value();
void set_value(int v);
static Singelton* getInstance();
};
#endif
.cpp
#include "Singelton.h"
Singelton* Singelton::instance = NULL;
Singelton::Singelton()
{
value=0;
}
Singelton* Singelton::getInstance()
{
if (instance == NULL)
{
instance = new Singelton();
}
return instance;
}
Singelton::~Singelton()
{
instance = NULL;
}
int get_value()
{
return value;
}
void set_value(int v)
{
value=v;
}