#pragma once
class B
{
private:
static int s_nValue;
public:
B();
~B();
static int GetValue() { return s_nValue; }
static void SetValue(int value){ s_nValue = value; }
};
int _tmain(int argc, _TCHAR* argv[])
{
int i = 0;
B::SetValue(5);
std::cout << B::GetValue();
cin>> i;
return 0;
}
I'm trying to master the use of static functions. In this case, SetValue() and GetValue() are defined in class B. They are called without an object definition in main. This should work, but I'm getting an unresolved external symbol error 2001. The precompiled headers option is turned off.
How can I get rid of this error?
Using MS Visual Studio 2012