- Table of Contents
- Copyright
- About the Authors
- About the Contributors
- Acknowledgments
- Tell Us What You Think!
- Introduction
- How to Use This Book
- What You Need to Use This Book
- What's New in Visual C++ 6.0
- Contacting the Main Author
- Part I: Introduction
- Chapter 1. The Visual C++ 6.0 Environment
- Part II: MFC Programming
- Chapter 2. MFC Class Library Overview
- Chapter 3. MFC Message Handling Mechanism
- Chapter 4. The Document View Architecture
- Chapter 5. Creating and Using Dialog Boxes
- Chapter 6. Working with Device Contexts and GDI Objects
- Chapter 7. Creating and Using Property Sheets
- Chapter 8. Working with the File System
- Chapter 9. Using Serialization with File and Archive Objects
- Part III: Internet Programming with MFC
- Chapter 10. MFC and the Internet Server API (ISAPI)
- Chapter 11. The WinInet API
- Chapter 12. MFC HTML Support
- Part IV: Advanced Programming Topics
- Chapter 13. Using the Standard C++ Library
- Chapter 14. Error Detection and Exception Handling Techniques
- Chapter 15. Debugging and Profiling Strategies
- Chapter 16. Multithreading
- Chapter 17. Using Scripting and Other Tools to Automate the Visual C++ IDE
- Part V: Database Programming
- Chapter 18. Creating Custom AppWizards
- Chapter 19. Database Overview
- Chapter 20. ODBC Programming
- Chapter 21. MFC Database Classes
- Chapter 22. Using OLE DB
- Chapter 23. Programming with ADO
- Part VI: MFC Support for COM and ActiveX
- Chapter 24. Overview of COM and Active Technologies
- Chapter 25. Active Documents
- Chapter 26. Active Containers
- Chapter 27. Active Servers
- Chapter 28. ActiveX Controls
- Part VII: Using the Active Template Library
- Chapter 29. ATL Architecture
- Chapter 30. Creating COM Objects Using ATL
- Chapter 31. Creating ActiveX Controls Using ATL
- Chapter 32. Using ATL to Create MTS and COM+ Components
- Part VIII: Finishing Touches
- Chapter 33. Adding Windows Help
- Part IX: Appendix
Summary
In this chapter, you examined structured exception handling. You saw what exceptions are and how to handle them so that they will not force your program to come to a crashing halt. You also learned the difference between hardware exceptions and software exceptions.
Although you learned that SEH is not really intended to be used with C++ but with C, the SEH concepts carry over to what you can use with C++: C++ exception handling.
You saw how to use C++ exception handling to deal with the relationship of an application and a class member. You learned about throwing an exception and catching one.
You also looked at how to guard your code with try and then how to call exception code in the catch block after the exception is thrown. Using these keywords, you were able to recover sample programs from exception errors.
After checking out a few examples, you looked at the capabilities of multiple exception handling—how the same class can handle more than one exception. You then looked at using arguments with exceptions. You created an example that passes arguments to the class member so that the exception error can return specific information, such as the function name that caused the error and what values contributed to the exception.
You also looked at MFC error and exception handling. You briefly examined MFC macros. MFC macros were the original way to handle exception errors in early MFC versions. For MFC 3.0 and later, you can use the C++ exception mechanism.
Although all later versions of MFC support macros, it is recommended to use the C++ exception mechanism, and to use macros only to support older programs that previously used them.
Finally, you learned about MFC exception handling, which is C++ exception handling with the MFC predefined exceptions. You were briefly introduced to each predefined exception, and you explored how to generate custom exception classes.
Chapter 15. Debugging and Profiling Strategies | Next Section

Account Sign In
View your cart