Absolute C++ (4th Edition) part 17

Absolute C++ (4th Edition) part 17. KEY BENEFIT: C++ programming concepts and techniques are presented in a straightforward style using understandable language and code. KEY TOPICS: C++ Basics; Flow of Control; Function Basics; Parameters and Overloading; Arrays; Structures and Classes; Constructors; Operator Overloading, Friends, and References; Strings; Pointers and Dynamic Arrays; Separate Compilation and Namespaces; Streams and File I/O; Recursion; Inheritance; Polymorphism and Virtual Functions; Templates; Linked Data Structures; Exception Handling; Standard Template Library; Patterns and UML. MARKET: Useful for both beginning and intermediate C++ programmers. . | 162 Parameters and Overloading of coins of denomination coinValue cents that can be obtained from amountLeft cents. amountLeft has been decreased by the value of the coins that is decreased by number coinValue. You can check that the precondition holds for a function invocation as shown by the following example assert 0 currentCoin currentCoin 100 0 currentAmountLeft currentAmountLeft 100 computeCoin currentCoin number currentAmountLeft If the precondition is not satisfied your program will end and an error message will be output. The assert macro is defined in the library cassert so any program that uses the assert macro must contain the following include cassert turning off One advantage of using assert is that you can turn assert invocations off. You can use assert invocations in your program to debug your program and then turn them off so that users do not get error messages that they might not understand. Doing so reduces the overhead performed by your program. To turn off all the define NDEBUG assertions define in your program add define NDEBUG before the include directive as follows NDEBUG define NDEBUG include cassert Thus if you insert define NDEBUG in your program after it is fully debugged all assert invocations in your program will be turned off. If you later change your program and need to debug it again you can turn the assert invocations back on by deleting the define NDEBUG line or commenting it out . Not all comment assertions can easily be translated into C Boolean expressions. Preconditions are more likely to translate easily than postconditions are. Thus the assert macro is not a cure-all for debugging your functions but it can be very useful. STUBS AND DRIVERS Each function should be designed coded and tested as a separate unit from the rest of the program. When you treat each function as a separate unit you transform one big task into a series of smaller more manageable tasks. But how do you test a function outside the program for which it is

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.