Lecture Programming languages (2/e): Chapter 7b - Tucker, Noonan

7b - Exception handling semantics. In this section, we summarize the I/0 error handling features of recent versions of Fortran, C++. and Ada. This treatment provides a convenient prelude to section , which covers the more general topic of exception handling semantics. | Programming Languages 2nd edition Tucker and Noonan Chapter 7 Semantics Ismael: “Surely all this is not without meaning.” Herman Melville, Moby Dick Contents Motivation Expression Semantics Program State Assignment Semantics Control Flow Semantics Input/Output Semantics Exception Handling Semantics Purpose Simplify programming Make applications more robust. What does robust mean? (* Pascal - what can go wrong *) reset(file, name); (* open *) sum := ; count := 0; while (not eof(file)) do begin read(file, number); sum := sum + number; count := count + 1; end; ave := sum / count; Exception Handling Figure #include int main () { char A[10]; cin >> n; try { for (int i=0; i9) throw "array index error"; A[i]=getchar(); } } catch (char* s) { cout int main () { char A[10]; cin >> n; try { for (int i=0; i9) throw "array index error"; A[i]=getchar(); } } catch (char* s) { cout int main () { char A[10]; cin >> n; try { for (int i=0; i9) throw "array index error"; A[i]=getchar(); } } catch (char* s) { cout << "Exception: " << s << endl; } return 0; } Java Exception Type Hierarchy Figure Creating a New Exception Class Missing Argument Exception Invalid Input Exception Figure StackUnderflowException Class Figure Throwing an Exception Figure AssertException Class Assert Class Figure Using Asserts

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
5    69    2    01-05-2024
Đã 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.