Summary
In this chapter, we looked at the use of C++ classes as a program-building tool. The use of classes eliminates the drawbacks of using global functions as the tools of object-oriented programming.
The first drawback of using global functions is that it does not necessarily indicate to the maintainer what the designer knows at the time of coding, that the functions accessing the same data structure logically belong together.
If, for example, the program uses Point and Rectangle data structures, and the designer puts all Point access functions together and all Rectangle access functions together, fine. If the access functions are separate, the compiler is not going to complain, but the maintainer is going to be confused. Hence, the discipline ...
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