As you proceed in your programming career, the problems/tasks that need solving become more complex. The documentation of the algorithm done in pseudo code (or some other method) will still need to be converted into a programming solution. Inevitably, when writing that source code mistakes will be introduced. When learning the syntax of a new programming language, programmers sometimes automatically think in their old language syntax, and make mistakes that are sometimes hard to detect.
The concept of using a fag to either activate or have remain dormant certain lines of code designed solely to help with the debugging of a program has existed since almost the beginning of modern computer programming (1950's). One of the debugging tools available within C++ is conditional compilation. For our fag, we would use a defined constant like:
#define DEBUG l
Then using another compiler directive pair, the if and endif, we can have the compiler during the pre-processor either include or not include one or more lines of code.
#if DEBUG cout « "\n***** DEBUG Code ** Hi mom!"; #endif
Of course saying "Hi mom!" is not very useful for debugging your code. However, you can use test data with conditional compilation. A series of input data values and a series of output predictors can be placed in the program. Then you can turn on the debug feature or turn them of with your debugging fag.
You should study the demonstration program in conjunction with this module.