Absolute C++ (4th Edition) part 49

Absolute C++ (4th Edition) part 49. 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. . | Namespaces 487 Display Hiding the Helping Functions in a Namespace Implementation File part 3 of 3 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 cout Error illegal input to readHour n exit 1 unnamed namespace namespace DTimeSavitch Uses iostream istream operator istream ins DigitalTime theObject readHour readMinute return ins Within the compilation unit in this case you can use names in the unnamed namespace without qualification. ostream operator ostream outs const DigitalTime theObject The body of the function definition is the same as in Display . bool operator const DigitalTime timel const DigitalTime time2 The body of the function definition is the same as in Display . DigitalTime DigitalTime int theHour int theMinute The body of the function definition is the same as in Display . DigitalTime DigitalTime The body of the function definition is the same as in Display . int DigitalTime getHour const The body of the function definition is the same as in Display . int DigitalTime getMinute const The body of the function definition is the same as in Display . void DigitalTime advance int minutesAdded The body of the function definition is the same as in Display . void DigitalTime advance int hoursAdded int minutesAdded The body of the function definition is the same as in Display . DTimeSavitch 488 Separate Compilation and Namespaces and implementation file for the class DigitalTime. Note that the helping functions readHour readMinute and digitToInt are all in the unnamed namespace thus they are local to the compilation unit. As illustrated in Display the names in the unnamed namespace can be reused for something else outside the compilation unit. In Display the function name readHour is reused for a different function in the application program. Display Hiding the Helping Functions in a Namespace Application Program part i of 2 1 2 This is the

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.