⟩ What is static class data?
Static data members of a class are declared by preceding the member variable’s declaration with the keyword static. Only one copy of static data members exist and all objects of the class share that variable. Unlike regular data members, individual copies of a static member variable are not made for each object. How many ever no of objects of a class are created, only one copy of static data member is shared amongst all of them. All static variables are initialized to zero before the first object is created.
When a member variable is declared static within a class, it is not defined (ie storage is not allocated for it) We must provide a global definition for it outside the class. This is done by redeclaring the static variable using scope resolution operator (‘::’) to identify the class it belongs to. This causes storage for the class to be allocated.