C++初学者有关问题,为什么上面的代码说 error LNK2001: 无法解析的外部符号 "public: static int A:sta" (?sta@A@@

C++菜鸟问题,为什么下面的代码说 error LNK2001: 无法解析的外部符号 "public: static int A::sta" (?sta@A@@
class A 
{
public:
void print()
{
cout<<"a = "<<a<<'\n'<<"b = "<<b<<endl;
cout<<"str = "<<str<<endl;
cout<<"de = "<<de<<endl;
}
A():a(0),b(0){}
A(int c, double d )
{
  a = c;
b = d;
}
static int sta;
private:
int a;
double b;
int de;

string str;
};



int _tmain(int argc, _TCHAR* argv[])
{
A::sta = 999;
A a;
a.print();
cout<< A::sta<<endl;
return 0;
}

------解决方案--------------------
加一句int A::sta = 0;
类的静态成员变量需要这样子定义。
------解决方案--------------------
变量sta必须在函数体外定义,把这行代码A::sta = 999;移到_main函数体外边。
------解决方案--------------------
楼上正解
------解决方案--------------------
探讨
引用:

变量sta必须在函数体外定义,把这行代码A::sta = 999;移到_main函数体外边。


把A::sta = 999;改为int A::sta = 999;