C++ 中static 使用大全

/// 静态全局变量 :只能在当前cpp中访问到 
static int s_global = 0;
void funcA() {
     /// 静态局部变量 (函数静态变量) 初始化过一次就不会被覆盖 
     static int s_funcValue = 1;
}
class Animal {
public:
       /// 静态成员变量: 可以 Animal::s_val访问 
       static int s_val;
       
       /// 静态成员函数 : 可以 Animal::funcStatic()调用 
       static int funcStatic() {
              return 0;
       }
};
/// 静态成员变量必须定义一次 
int Animal::s_val = 2;
/// 静态全局函数 : 只能在当前cpp中访问到 
static void globalStatic() {
}
int main() {
    return 0;
}
原文地址:https://www.cnblogs.com/wxmdevelop/p/4596255.html