TAILIEUCHUNG - A Complete Guide to Programming in C++ part 32

A Complete Guide to Programming in C++ part 32. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | EXERCISES 289 Exercise 2 In the exercises for chapter 13 an initial version of the Date class containing members for day month and year was defined. Now extend this class to add additional methods are shown on the opposite page. The constructors and the method setDate replace the init method used in the former default constructor uses default values for example to initialize the objects in setDate method without any parameters writes the current date to the object. The constructor and the setDate method with three parameters do not need to perform range functionality will be added in the next exercise. The methods isEqual and isLess enable comparisons with a date passed to them. The method asString returns a reference to a string containing the date in the format mm-dd-year . will therefore need to convert any numerical values into their corresponding decimal strings. This operation is performed automatically when you use the operator to output a number to the standard output cout. In addition to the cin and cout streams with which you are already familiar so-called string streams with the same functionality also exist. However a string stream does not read keyboard input or output data on screen. Instead the target or source is a buffer in main allows you to perform formatting and conversion in main memory. Use an application program that calls all the methods defined in the class to test the Date class. Exercise 3 The Date class does not ensure that an object represents a valid avoid this issue add range checking functionality to the class. Range checking is performed by the constructor and the setDate method with three parameters. First write a function called isLeapYear that belongs to the bool type and checks whether the year passed to it is a leap year. Define the function as a global inline function and store it in the header file . Modify the setDate .

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