A static member of a class cannot be initialized by the constructor of a class. Because even if no object of the class exists, the static members of the class still exist and can be used. The static members of a class also cannot access non-static members of any class.
Both the class name and the class object can call static data members directly. Because a static data member already exists before the constructor is executed.
However, if the static member is integer or enumerated const, you can initialize it in the class declaration !
The static decorated function indicates that the function belongs to a class, not to an object, and does not have the this pointer.
A member variable in a C + + class is declared as static, whichmeans that it is shared by all instances of the class , that is, when an instance of a class modifies the static member variable, This means that no matter how many objects are created, thestatic modified variable occupies only one piece of memory . Its modified value is seen by all other instances of the class, and static member functions of the class can access only static members (variables or functions). Static is a global variable that adds access control and is not inherited.
Static data members in C + +