静态作用域(static scope,也叫lexical scope,字面作用域),是一种根据语言文本的位置确定变量引用的规则。 它的意思是,某个变量到底是什么值,是由program text决定的,说白了,你写code的时候定义变量的位置在哪儿就哪儿。完全是根据文本位置决定的,而不管函数在哪里调用(哪怕在别的对象里)。
标准 C 允许使用需要引用自身的表达式初始化对象或变量,但只适用于非静态作用域的对象。
Standard C allows for the initialization of an object or variable with an expression involving a reference to itself, but only for objects of nonstatic extent.
这些属性的作用域是静态定义的。
静态函数与静态属性一样,作用域也是类而非该类的对象实例。
Static functions, like static properties, are scoped to the class rather than to object instances of that class.
应用推荐