[class.static.data]

# 11 Classes [[class]](./#class)

## 11.4 Class members [[class.mem]](class.mem#class.static.data)

### 11.4.9 Static members [[class.static]](class.static#data)

#### 11.4.9.3 Static data members [class.static.data]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L2783)

A static data member is not part of the subobjects of a class[.](#1.sentence-1)

If a
static data member is declared thread_local there is one copy of
the member per thread[.](#1.sentence-2)

If a static data member is not declaredthread_local there is one copy of the data member that is shared by all
the objects of the class[.](#1.sentence-3)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L2790)

A static data member shall not be mutable ([[dcl.stc]](dcl.stc "9.2.2 Storage class specifiers"))[.](#2.sentence-1)

A static data member shall not be a direct member ([[class.mem]](class.mem "11.4 Class members"))
of an unnamed ([[class.pre]](class.pre "11.1 Preamble")) or local ([[class.local]](class.local "11.6 Local class declarations")) class or
of a (possibly indirectly) nested class ([[class.nest]](class.nest "11.4.12 Nested class declarations")) thereof[.](#2.sentence-2)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L2796)

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 thancv void[.](#3.sentence-1)

[*Note [1](#note-1)*:

The [*initializer*](dcl.init.general#nt:initializer "9.5.1 General [dcl.init.general]") in the definition of a
static data member is in the scope of its
class ([[basic.scope.class]](basic.scope.class "6.4.7 Class scope"))[.](#3.sentence-2)

â *end note*]

[*Example [1](#example-1)*: class process {static process* run_chain; static process* running;};

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

The definition of the static data member run_chain of classprocess inhabits the global scope; the notationprocess​::​run_chain indicates that the member run_chain is a member of class process and in the scope of classprocess[.](#3.sentence-3)

In the static data member definition, the[*initializer*](dcl.init.general#nt:initializer "9.5.1 General [dcl.init.general]") expression refers to the static data
member running of class process[.](#3.sentence-4)

â *end example*]

[*Note [2](#note-2)*:

Once the static data member has been defined, it exists even if
no objects of its class have been created[.](#3.sentence-5)

[*Example [2](#example-2)*:

In the example above, run_chain and running exist even
if no objects of class process are created by the program[.](#3.sentence-6)

â *end example*]

The initialization and destruction of static data members is described in[[basic.start.static]](basic.start.static "6.10.3.2 Static initialization"), [[basic.start.dynamic]](basic.start.dynamic "6.10.3.3 Dynamic initialization of non-block variables"), and [[basic.start.term]](basic.start.term "6.10.3.4 Termination")[.](#3.sentence-7)

â *end note*]

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L2840)

If a non-volatile non-inline const static data member is
of integral or enumeration type,
its declaration in the class definition can specify a[*brace-or-equal-initializer*](dcl.init.general#nt:brace-or-equal-initializer "9.5.1 General [dcl.init.general]") in which every[*initializer-clause*](dcl.init.general#nt:initializer-clause "9.5.1 General [dcl.init.general]") that is an [*assignment-expression*](expr.assign#nt:assignment-expression "7.6.19 Assignment and compound assignment operators [expr.assign]") is a constant expression ([[expr.const]](expr.const "7.7 Constant expressions"))[.](#4.sentence-1)

The member shall still be defined in a namespace scope if
it is odr-used ([[basic.def.odr]](basic.def.odr#term.odr.use "6.3 One-definition rule")) in the program and the
namespace scope definition shall not contain an [*initializer*](dcl.init.general#nt:initializer "9.5.1 General [dcl.init.general]")[.](#4.sentence-2)

The declaration of an inline static data member (which is a definition)
may specify a [*brace-or-equal-initializer*](dcl.init.general#nt:brace-or-equal-initializer "9.5.1 General [dcl.init.general]")[.](#4.sentence-3)

If the
member is declared with the constexpr specifier, it may be
redeclared in namespace scope with no initializer (this usage is
deprecated; see [[depr.static.constexpr]](depr.static.constexpr "D.7 Redeclaration of static constexpr data members"))[.](#4.sentence-4)

Declarations of other
static data members shall not specify a [*brace-or-equal-initializer*](dcl.init.general#nt:brace-or-equal-initializer "9.5.1 General [dcl.init.general]")[.](#4.sentence-5)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L2857)

[*Note [3](#note-3)*:

There is exactly one definition of a static data member
that is odr-used ([[basic.def.odr]](basic.def.odr#term.odr.use "6.3 One-definition rule")) in a valid program[.](#5.sentence-1)

â *end note*]

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/classes.tex#L2863)

[*Note [4](#note-4)*:

Static data members of a class in namespace scope have the linkage of the name of the class ([[basic.link]](basic.link "6.7 Program and linkage"))[.](#6.sentence-1)

â *end note*]
