Chapter 8
Debugging Your Programs, Part I
In This Chapter
Avoiding introducing errors needlessly
Creating test cases
Peeking into the inner workings of your program
Fixing and retesting your programs
You may have noticed that your programs often don’t work the first time you run them. In fact, I have seldom, if ever, written a nontrivial C++ program that didn’t have some type of error the first time I tried to execute it.
This leaves you with two alternatives: You can abandon a program that has an error, or you can find and fix the error. I assume that you want to take the latter approach. In this chapter, I first help you distinguish between types of errors and show you how to avoid errors in the first place. Then you get to find and eradicate two bugs that originally plagued the Conversion program in Chapter 3.
Identifying Types of Errors
Two types of errors exist — those that C++ can catch on its own and those that the compiler can’t catch. Errors that C++ can catch are known as compile-time or build-time errors. Build-time errors are generally easier to fix because the compiler ...
Get Beginning Programming with C++ For Dummies, 2nd 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.