2.3. Declaring Data Members
A data member represents state information associated with an instance of a class, such as the name of a file or the capacity of an ArrayList. A class data member can be of any type. How do we discover the data members that we need to associate with a class?
One category of data members is the set that users provide when they create a class instance. For example, for our WordCount class, we require users to provide the name of a text file and optionally to indicate whether they wish a program trace or performance timings. It is likely that we'll need to store these values in associated class data members.
A second category of data members is the set of objects that are used across multiple member functions. If an object ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access