Đang chuẩn bị liên kết để tải về tài liệu:
Chapter 13 - Exception Handling

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

Exception handling is the process of responding to the occurrence, during computation, of exceptions – anomalous or exceptional events requiring special processing – often changing the normal flow of program execution. It is provided by specialized programming language constructs or computer hardware mechanisms. | Chapter 13 - Exception Handling Outline 13.1 Introduction 13.2 Exception-Handling Overview 13.3 Other Error-Handling Techniques 13.4 Simple Exception-Handling Example: Divide by Zero 13.5 Rethrowing an Exception 13.6 Exception Specifications 13.7 Processing Unexpected Exceptions 13.8 Stack Unwinding 13.9 Constructors, Destructors and Exception Handling 13.10 Exceptions and Inheritance 13.11 Processing new Failures 13.12 Class auto_ptr and Dynamic Memory Allocation 13.13 Standard Library Exception Hierarchy 13.1 Introduction Exceptions Indicates problem occurred in program Not common An "exception" to a program that usually works Exception Handling Resolve exceptions Program may be able to continue Controlled termination Write fault-tolerant programs As an example, we will handle a divide-by-zero error 13.2 Exception-Handling Overview Consider pseudocode Perform a task If the preceding task did not execute correctly Perform error processing Perform next task If the preceding . | Chapter 13 - Exception Handling Outline 13.1 Introduction 13.2 Exception-Handling Overview 13.3 Other Error-Handling Techniques 13.4 Simple Exception-Handling Example: Divide by Zero 13.5 Rethrowing an Exception 13.6 Exception Specifications 13.7 Processing Unexpected Exceptions 13.8 Stack Unwinding 13.9 Constructors, Destructors and Exception Handling 13.10 Exceptions and Inheritance 13.11 Processing new Failures 13.12 Class auto_ptr and Dynamic Memory Allocation 13.13 Standard Library Exception Hierarchy 13.1 Introduction Exceptions Indicates problem occurred in program Not common An "exception" to a program that usually works Exception Handling Resolve exceptions Program may be able to continue Controlled termination Write fault-tolerant programs As an example, we will handle a divide-by-zero error 13.2 Exception-Handling Overview Consider pseudocode Perform a task If the preceding task did not execute correctly Perform error processing Perform next task If the preceding task did not execute correctly Perform error processing Mixing logic and error handling Can make program difficult to read/debug Exception handling removes error correction from "main line" of program 13.2 Exception-Handling Overview Exception handling For synchronous errors (divide by zero, null pointer) Cannot handle asynchronous errors (independent of program) Disk I/O, mouse, keyboard, network messages Easy to handle errors Terminology Function that has error throws an exception Exception handler (if it exists) can deal with problem Catches and handles exception If no exception handler, uncaught exception Could terminate program 13.2 Exception-Handling Overview C++ code try { code that may raise exception } catch (exceptionType){ code to handle exception } try block encloses code that may raise exception One or more catch blocks follow Catch and handle exception, if appropriate Take parameter; if named, can access exception object 13.2 Exception-Handling Overview Throw

crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.