| Defining a static data member in the class definition A static data member of the class may be fully defined within the class definition if it is declared inline. For example, the following class may be defined in a header. Prior to C++17, it would have been necessary to provide a .cpp file to contain the definition of Foo::num_instances so that it would be defined only once, but in C++17 the multiple definitions of the inline variable Foo::num_instances all refer to the same int object. As a special case, a constexpr static data member is implicitly inline. |