相关疑难解决方法(0)

在C++中查询类的静态成员变量

对不起,如果这个问题对很多人来说似乎微不足道.

在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)
  1. 当'bands'一次在类中声明为static时,为什么上述语句需要再次使用?

  2. 静态变量也可以在任何类中声明为私有成员变量吗?

c++ variables static class

1
推荐指数
1
解决办法
2065
查看次数

标签 统计

c++ ×1

class ×1

static ×1

variables ×1