TAILIEUCHUNG - C++ Programming for Games Module II phần 2

Tham khảo tài liệu 'c++ programming for games module ii phần 2', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Introduction Throughout most of the previous chapters we have assumed that all of our code was designed and implemented correctly and that the results could be anticipated. For example we assumed that the user entered the expected kind of input such as a string when a string was expected or a number when a number was expected. Additionally we assumed that the arguments we passed into function parameters were valid. But this may not always be true. For example what happens if we pass in a negative integer into a factorial function which expects an integer greater than or equal to zero Whenever we allocated memory we assumed that the memory allocation succeeded but this is not always true because memory is finite and can run out. While we copied strings with strcpy we assumed the destination string receiving the copy had enough characters to store a copy but what would happen if it did not It would be desirable if everything worked according to plan however in reality things tend to obey Murphy s Law which paraphrased says if anything can go wrong it will . In this chapter we spend some time getting familiar with several ways in which we can catch and handle errors. The overall goal is to write code that is easy to debug can possibly recover from errors and exits gracefully with useful error information if the program encounters a fatal error. Chapter Objectives Understand the method of catching errors via function return codes and an understanding of the shortcomings of this method. Become familiar with the concepts of exception handling its syntax and its benefits. Learn how to write assumption verification code using asserts. Error Codes The method of using error codes is simple. For every function or method we write we have it return a value which signifies whether the function method executed successfully or not. If it succeeded then we return a code that signifies success. If it failed then we return a predefined value that specifies where and why the .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.