0%

Book Description

It’s easy to make lots of programming mistakes in C++—in fact, any program over a few hundred lines is likely to contain bugs. With this book, you’ll learn about many common coding errors that C++ programmers produce, along with rules and strategies you can use to avoid them. You’ll not only find recipes for identifying errors during your program’s compilation, runtime, and testing phases, you’ll learn a comprehensive approach for making your C++ code safe and bug-free.

Table of Contents

  1. Safe C++
  2. Dedication
  3. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  4. Preface
    1. Audience
    2. How This Book Is Organized
    3. Conventions Used in This Book
    4. Naming Conventions
    5. Using Code Examples
    6. Safari® Books Online
    7. How to Contact Us
    8. Acknowledgments
  5. I. A Bug-Hunting Strategy for C++
    1. 1. Where Do C++ Bugs Come From?
    2. 2. When to Catch a Bug
      1. Why the Compiler Is Your Best Place to Catch Bugs
      2. How to Catch Bugs in the Compiler
      3. The Proper Way to Handle Types
    3. 3. What to Do When We Encounter an Error at Runtime
  6. II. Bug Hunting: One Bug at a Time
    1. 4. Index Out of Bounds
      1. Dynamic Arrays
      2. Static Arrays
      3. Multidimensional Arrays
    2. 5. Pointer Arithmetic
    3. 6. Invalid Pointers, References, and Iterators
    4. 7. Uninitialized Variables
      1. Initialized Numbers (int, double, etc.)
      2. Uninitialized Boolean
    5. 8. Memory Leaks
      1. Reference Counting Pointers
      2. Scoped Pointers
      3. Enforcing Ownership with Smart Pointers
    6. 9. Dereferencing NULL Pointers
    7. 10. Copy Constructors and Assignment Operators
    8. 11. Avoid Writing Code in Destructors
    9. 12. How to Write Consistent Comparison Operators
    10. 13. Errors When Using Standard C Libraries
  7. III. The Joy of Bug Hunting: From Testing to Debugging to Production
    1. 14. General Testing Principles
    2. 15. Debug-On-Error Strategy
    3. 16. Making Your Code Debugger-Friendly
    4. 17. Conclusion
    5. A. Source Code for the scpp Library Used in This Book
    6. B. Source Code for the files scpp_assert.hpp and scpp_assert.cpp
    7. C. Source Code for the file scpp_vector.hpp
    8. D. Source Code for the file scpp_array.hpp
    9. E. Source Code for the file scpp_matrix.hpp
    10. F. Source Code for the file scpp_types.hpp
    11. G. Source Code for the file scpp_refcountptr.hpp
    12. H. Source Code for the file scpp_scopedptr.hpp
    13. I. Source Code for the file scpp_ptr.hpp
    14. J. Source Code for the file scpp_date.hpp and scpp_date.cpp
  8. Index
  9. About the Author
  10. Colophon
  11. SPECIAL OFFER: Upgrade this ebook with O’Reilly
  12. Copyright
3.139.97.202