Use of “static” in c++
Use of “static” in c++ | |
---|---|
static free functions | |
static global variables | |
static local variables | Persistent storage |
static member variables | Shared by all instance |
static member functions | Shared by all instance can only access static member variables |
static含义
- 访问特性:只能在当前访问
- 存储特性:持续存储
static local variables:相当于在特定区域内访问的全局变量
static member variables :该特性属于类,类的对象共有