EECS 211
How to Read Deitel and Deitel

The good thing about Deitel and Deitel's C++ How to Program is that it has a ton of information.

The bad thing about Deitel and Deitel's C++ How to Program is that it has a ton of information.

Don't panic! Yes, it's 1400 pages of tiny print, but we're not going to do all of it. And, yes, there's a lot of sections assigned in the syllabus. But many of those sections are quite short, often just a page or two. Furthermore, the book has many pages with

The best way to tackle the book is in multiple scans, focusing on the example pieces of code in the figures first. For example, the syllabus says to read Sections 2.1 through 2.7. So start with Figure 2.1. That's a pretty simple piece of code for printing strings. There are comments on virtually every line explaining what the line does.

Do not put such comments in your own code. Code should explain itself through good names, good layout, and modular structure. Textbook code has comments because it's for teaching. Such comments are clutter in real code.

Does the example make sense? Do you think you know how to change that code to do something similar? Then try it. Make a file with the example. No need to type anything. All the code is on the CD. You can also get it from the Deitel book site (registration required).

Compile and run the example unchanged. If it works, then change it a little bit. Compile and run the new version. If it does what you expected, move on to the next piece of code.

While the code in Deitel and Deitel has improved over various editions, they still do things not recommended by serious programmers. Always check the C++ style guide before copying their code.

In Chapter 2, the next two pieces of code (Figures 2.3 and 2.4) are trivial variations of Figure 2. The next piece of really new code is Figure 2.5. It introduces reading some values from the console, calculating a result, and printing it. None of the concepts should be new to you, just the form in which you do this in C++.

Repeat the above process. Compile and run the code unchanged. Then modify it to do something else, e.g., multiply the numbers instead of add.

When you run into trouble, or something happens you can't explain, or you're not sure how to change the code to do something you think should be easy, read the text. If that doesn't help, post to the newsgroup. If that doesn't work, contact the TA or bring it up in class.