A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://timsong-cpp.github.io/cppwp/n4659/class.static.data below:

[class.static.data]

12 Classes [class] 12.2 Class members [class.mem] 12.2.3 Static members [class.static] 12.2.3.2 Static data members [class.static.data]

A static data member is not part of the subobjects of a class. If a static data member is declared thread_­local there is one copy of the member per thread. If a static data member is not declared thread_­local there is one copy of the data member that is shared by all the objects of the class.

The declaration of a non-inline static data member in its class definition is not a definition and may be of an incomplete type other than cv void. The definition for a static data member that is not defined inline in the class definition shall appear in a namespace scope enclosing the member's class definition. In the definition at namespace scope, the name of the static data member shall be qualified by its class name using the ​::​ operator. The initializer expression in the definition of a static data member is in the scope of its class ([basic.scope.class]). [Example:

class process {
  static process* run_chain;
  static process* running;
};

process* process::running = get_main();
process* process::run_chain = running;

The static data member run_­chain of class process is defined in global scope; the notation process​::​run_­chain specifies that the member run_­chain is a member of class process and in the scope of class process. In the static data member definition, the initializer expression refers to the static data member running of class process. end example]

[Note: Once the static data member has been defined, it exists even if no objects of its class have been created. [Example: In the example above, run_­chain and running exist even if no objects of class process are created by the program. end example] end note]

[Note: There shall be exactly one definition of a static data member that is odr-used in a program; no diagnostic is required. end note] Unnamed classes and classes contained directly or indirectly within unnamed classes shall not contain static data members.

[Note: Static data members of a class in namespace scope have the linkage of that class. A local class cannot have static data members. end note]

A static data member shall not be mutable.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4