对不起,如果这个问题对很多人来说似乎微不足道.
在C++代码中,有如下内容:
class Foo
{
public:
static int bands;
...
...
private:
...
...
}//class definition ends
int Foo::bands; //Note: here its not initialized to any value!
Run Code Online (Sandbox Code Playgroud)
当'bands'一次在类中声明为static时,为什么上述语句需要再次使用?
静态变量也可以在任何类中声明为私有成员变量吗?