tailieunhanh - The C++ Programming Language Third Edition phần 3

Các lập trình viên có thể lựa chọn giữa các phiên bản trên cơ sở hợp lý và thẩm mỹ. Kết quả của việc áp dụng các nhà khai thác số học +, -, + +, hoặc con trỏ phụ thuộc vào loại của đối tượng chỉ ra. Khi một nhà điều hành số học được áp dụng cho một con trỏ p của loại T p T *, | Section Exercises 195 6. 2 Modify the program from 5 to measure if there is a difference in the cost of catching exceptions depending on where in a class stack the exception is thrown. Add a string object to each function and measure again. 7. 1 Find the error in the first version ofmain in . 8. 2 Write a function that either returns a value or that throws that value based on an argument. Measure the difference in run-time between the two ways. 9. 2 Modify the calculator version from 3 to use exceptions. Keep a record of the mistakes you make. Suggest ways of avoiding such mistakes in the future. 10. Write plus minus multiply and divide functions that check for possible overflow and underflow and that throw exceptions if such errors happen. 11. 2 Modify the calculator to use the functions from 10 . 196 Namespaces and Exceptions Chapter 8 9 Source Files and Programs Form must follow function. - Le Corbusier Separate compilation linking header files standard library headers the one-definition rule linkage to non-C code linkage and pointers to functions using headers to express modularity single-header organization multiple-header organization include guards programs advice exercises. Separate Compilation A file is the traditional unit of storage in a file system and the traditional unit of compilation. There are systems that do not store compile and present C programs to the programmer as sets of files. However the discussion here will concentrate on systems that employ the traditional use of files. Having a complete program in one file is usually impossible. In particular the code for the standard libraries and the operating system is typically not supplied in source form as part of a user s program. For realistically-sized applications. even havingall oftheuser sowncodc ina single file is both impractical and inconvenient. The way a program is organized into files can help emphasize its logical structure help a human .

TỪ KHÓA LIÊN QUAN
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.