相关内容:
- 父类的
static
变量和函数在派生类中依然可用,但是受访问性控制(比如,父类的private
域中的就不可访问),而且对static
变量来说,派生类和父类中的static
变量是共用空间的,这点在利用static
变量进行引用计数的时候要特别注意。 static
函数没有“虚函数”一说。- 静态变量并不是说其就不能改变值,不能改变值的量叫常量(即
const
), 其拥有的值是可变的 ,而且它会保持最新的值。说其静态,是因为它不会随着函数的调用和退出而发生变化。即上次调用函数的时候,如果我们给静态变量赋予某个值的话,下次函数调用时,这个值保持不变。 - 静态变量 类型说明符是
static
。