In This Chapter
Declaring static member data
Defining and using static member functions
Understanding why my static member function can’t call my other member functions
By default, data members are allocated on a per-object basis. For example, each person has his or her own name. You can also declare a member to be shared by all objects of a class by declaring that member static. The term static applies to both data members and member functions, although the meaning is slightly different. This chapter describes both types, beginning with static data members.
The programmer can make a data member common to all objects of the class by adding the keyword static to the declaration. Such members are called static data members. (I would be a little upset if they were called something else.)
Most properties are properties of the object. Using the well-worn (one might say, threadbare) student example, properties such as name, ID number, and courses are specific to the individual student. However, all students share some properties — for example, the number of students currently enrolled, ...