For there isn’t a job on the top of the earth the beggar don’t know, nor do.
In this chapter we create a complete program. Every step of the process is covered, from setting forth the requirements to testing the result.
Before we start, we need to decide what we are going to do. This is a very important step and is left out of far too many programming cycles.
This chapter’s program must fulfill several requirements. First, it must be long enough to demonstrate modular programming, but at the same time short enough to fit inside a single chapter. Second, it must be complex enough to demonstrate a wide range of C++ features, but simple enough for a novice C++ programmer to understand.
Finally, it must be useful. This is not so simple to define. What’s useful to one person might not be useful to another. We decided to refine this requirement and restate it as “It must be useful to C++ programmers.” The program we have selected reads C++ source files and generates simple statistics on the nesting of parentheses and the ratio of comments to code lines.
The specification for our statistics program is:
Preliminary Specification for a C++ Statistics Gathering Program Steve Oualline February 10, 2002
statistics about C++ source files and prints them. The command line
files is a list of
source files. Example 27-1
shows the output of the program on a short test file.