Chapter 22
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 ...
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