C++ ErrorsLesson 44Free preview
C++ Debugging
This lesson is part of C++ · All levels
Summary
Debugging is the process of finding and fixing bugs, from reading compiler messages, printing values with cout, to using a debugger with breakpoint and watch variable. A common strategy is to narrow down the problem areas: for the program to be small, test each section, then check the values that don't match the expectations. Once a bug is found, the trace of the debugging print should be removed or converted to an orderly log.
Key points
- Read the full error message: a line called a compiler often points to the actual problem.
- Cout debugging (printf-style) is quick to check values while running.
- The debugger provides breakpoints, step over/in, and watches to observe the program's state.
- Assert helps enforce the essential assumptions as the program runs.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.