Case Study: The Drawing Program Revisited

In Chapter 5, “Structures and Pointers,” the case study was a program to do drawings of common shapes. That program used a struct to keep information about each graphics shape. Unfortunately, this does not work very well if the shape isn't a simple rectangle or ellipse that can be described by two points, the lower left and upper right corners. You would have to put in a pointer, which might contain extra point data. So the first problem is how to force complicated shapes into a simple struct.

The second problem has to do with program organization. The previous program relied on case statements, and this gets awkward when shapes have other properties as well. For example, users would like to select graphics ...

Get C++ By Example: UnderC Learning Edition 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.