There is a very simple way of remembering of all 3 C++ meanings of static
I'm aware of. static
means "pretty much like global variable/function but only available directly in scope of..."
- "...this file" if it is in global scope.
- "...this function" if it is in a function (including member functions). Note that if you make classes and lambdas in a function, they are still in this scope. Lambda with an empty capture can access static variable of its "parent" function.
- "...this class" if it is in a class (including those declared with
struct
). This case is slightly different as you can access the variable/function through an object or by prefixing, but this is a little like asking the class or its object to provide you access to it, and it in fact can be denied (with private
). So the access isn't "direct".
In case of the presented C99 array syntax, this is something completely different and I assume it was there to not introduce new keywords, as others suggest.