You define the static member of period by writing const int abc::period; . You can provide an initializer in the class for a member of the static const class, but this is not a definition, but just a declaration.
9.4.2 / 4 - If a static data member is of type const integer or const, its declaration in the class definition may indicate a constant initializer, which should be an integral constant expression (5.19). In this case, the term can appear in integral constant expressions. A member still needs to be defined in the namespace area, if used in the program, and the namespace area definition should not contain an initializer.
Your code compiles even without a definition, because you do not take the address of a static member. Bjarne Stroustrup mentions in C ++ - the FAQ here is that you can take the address of a static member if (and only if) it has a class definition outside
source share