I studied this static class memeber for long time. then start to link it with static storage class concept. these two different usages cause different understanding:
- static members
- Storage class specifiers
- auto - automatic storage duration. (until C++11)
- register - automatic storage duration. Also hints to the compiler to place the object in the processor's register. (deprecated) (until C++17)
- static - static or thread storage duration and internal linkage.
- extern - static or thread storage duration and external linkage.
- thread_local - thread storage duration. (since C++11)
- mutable - does not affect storage duration or linkage. See const/volatile for the explanation.
- Scope
- C++ keywords: static
Inside a class definition, the keyword static declares members that are not bound to class instances. Outside a class definition, it has a different meaning: see storage duration..
The storage class specifiers are a part of the decl-specifier-seq of a name's declaration syntax.
Only one storage class specifier may appear in a declaration except that thread_local may be combined with static or with extern (since C++11).
Scope :Each name that appears in a C++ program is only visible in some possibly discontiguous portion of the source code called its scope.
Within a scope, unqualified name lookup can be used to associate the name with its declaration...
Usage:
No comments:
Post a Comment