Structured Play: Making Classes Do Things
In This Chapter
Adding member functions to a class
Defining the member function
Invoking the member function
Accessing one member from another member
Overloading member functions
Classes were introduced to the C language as a convenient way to group unalike-but-related data elements — for example, the Social Security number and name of the same person. (That’s the way I introduce them in Chapter 19.) C++ expanded the concept of classes to give them the ability to mimic objects in the real world. That’s the essence of the difference between C and C++.
In the previous chapter, I review at a high level the concept of object-oriented programming. In this chapter, I make it more concrete by examining the active features of a class that allow it to better mimic the object-oriented world we live in.
Activating Our Objects
C++ uses classes to simulate real-world objects. However, the classes in Chapter 19 are lacking in that regard because ...