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

Get Core C++ A Software Engineering Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.