Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Xử lý cho một khối thử cố gắng trong thứ tự xuất hiện. Điều đó làm cho nó có thể viết xử lý mà không bao giờ có thể được thực thi, ví dụ bằng cách đặt một xử lý cho một lớp học có nguồn gốc sau khi một xử lý cho một lớp cơ sở tương ứng. | 15- 4 Exception handling DRAFT 28 April 1995 15.3 Handling an exception 3 4 5 6 7 8 9 10 11 12 13 14 1 void f try g catch Overflow oo . catch Matherr mm . Here the Overflow handler will catch exceptions of type Overflow and the Matherr handler will catch exceptions of type Matherr and all types publicly derived from Matherr including Underflow and Zerodivide. The handlers for a try block are tried in order of appearance. That makes it possible to write handlers that can never be executed for example by placing a handler for a derived class after a handler for a corresponding base class. A . in a handler s exception-declaration functions similarly to . in a function parameter declaration it specifies a match for any exception. If present a . handler shall be the last handler for its try block. If no match is found among the handlers for a try block the search for a matching handler continues in a dynamically surrounding try block. An exception is considered handled upon entry to a handler. Note the stack will have been unwound at that point. If no matching handler is found in a program the function terminate 15.5.1 is called. Whether or not the stack is unwound before calling terminate is implementation-defined. Referring to any non-static member or base class of the object in the handler of a function-try-block of a constructor or destructor of the object results in undefined behavior. The fully constructed base classes and members of an object shall be destroyed before entering the handler of a function-try-block of a constructor or destructor for that object. The scope and lifetime of the parameters of a function or constructor extend into the handlers of a function-try-block. If the handlers of a function-try-block contain a jump into the body of a constructor or destructor the program is ill-formed. If a return statement appears in a handler offunction-try-block of a constructor the program is ill-formed. The exception being handled shall be rethrown if control