Why Storage from the Heap Makes Testing Critical

Every program should be tested every time it is changed. But as you saw in the last lesson, when you start using heap-allocated storage and pointers, the danger of a problem arising when the program runs (at runtime) is much greater. Just look at some of the errors you might encounter:

  • Uninitialized pointer

  • Pointer initialized to NULL

  • Deleting twice

  • Not deleting at all

  • Going past the bounds of an array

These problems may or may not have consequences anywhere near the place where the error occurred. They may, like the fourth error listed here, not have any apparent effect at all.

C++ compilers enforce good programming practices such as strong typing, but still allow many dangerous errors to occur. There are strategies for building more testable programs, but keep in mind that no amount of testing will uncover all problems.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.34.85