This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: C++ PROGRAMMING • Chapter 20 • Exceptions and Error Handling • Bugs, Errors, Mistakes, and Code Rot • Exceptions • A Word About Code Rot • Exceptions • How Exceptions Are Used • Listing 20.1. Raising an exception. • try Blocks • catch Blocks • Using try Blocks and catch Blocks • Catching Exceptions • More Than One catch Specification • Listing 20.2. Multiple exceptions. • Exception Hierarchies • Listing 20.3. Class hierarchies and exceptions . • Data in Exceptions and Naming Exception Objects • Listing 20.4. Getting data out of an exception object . • Listing 20.5. • Passing by reference and using virtual functions in exceptions. • Exceptions and Templates • Listing 20.6. Using exceptions with templates. • Exceptions Without Errors • Bugs and Debugging • Breakpoints • Watch Points • Examining Memory • Assembler • Summary • Q&A • Quiz • Exercises Chapter 20 Exceptions and Error Handling The code you've seen in this guide has been created for illustration purposes. It has not dealt with errors so that you would not be distracted from the central issues being presented. Real-world programs must take error conditions into consideration. ToChapter you will learn • What exceptions are. • How exceptions are used, and what issues they raise. • How to build exception hierarchies. • How exceptions fit into an overall error-handling approach. • What a debugger is. Bugs, Errors, Mistakes, and Code Rot All programs have bugs. The bigger the program, the more bugs, and many of those bugs actually "get out the door" and into final, released software. That this is true does not make it okay, and making robust, bug-free programs is the number-one priority of anyone serious about programming. The single biggest problem in the software industry is buggy, unstable code. The biggest expense in many major programming efforts is testing and fixing. The person who solves the problem of producing good, solid, bulletproof programs at low cost and on time will revolutionize the software industry. There are a number of discrete kinds of bugs that can trouble a program. The first is poor logic: The program does just what you asked, but you haven't thought through the algorithms properly. The second is syntactic: You used the wrong idiom, function, or structure. These two are the most common, and they are the ones most programmers are on the lookout for. Research and real-world experience have shown beyond a doubt that the later in the development process you find a problem, the more it costs to fix it. The least expensive problems or bugs to fix are the ones you manage to avoid creating. The next cheapest are those the compiler spots. The C++ standards force compilers to put a lot of energy into making more and more bugs show up at compile time....
View Full Document
This note was uploaded on 01/13/2012 for the course CS 131 taught by Professor Clayton during the Spring '08 term at Bethune Cookman.
- Spring '08