A static class member is a member that is associated with the class, rather than with individual objects of the class type. It exists outside any object of the class.
Advantages:
- Storage efficient.
- If a
staticmember of a class changes, each object of the class will use the new value of thatstaticmember. - A
staticdata member can have incomplete type. - A
staticmember (either a data member or a member function) can be used as a default argument.
Differences between ordinary members and static members:
- A
staticmember belongs to the class, an ordinary member belongs to objects of the class.