Home Segments Index Top Previous Next

Chapter 12:

How To Define Reader and Writer Member Functions

In Chapter 11, you learned that constructor member functions can help you to establish initial member-variable values. In this chapter, you learn that reader and writer functions can help you to refer to member-variable values and to assign values to member variables subsequent to initialization.

Note that reader and writer functions, as described in this chapter, have nothing to do with input–output programming, even though the words reader and writer are common in discussions of input–output programming.

Note also that constructor functions are part of the C++ language, whereas reader and writer functions are not. You should understand, however, that the use of reader and writer functions, as explained in this chapter, is recommended by many expert programmers, no matter what programming language you happen to use. You learn why in the hardcopy version of this book.