Absolute C++ (4th Edition) part 68

Absolute C++ (4th Edition) part 68. 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. . | Class Templates 677 Display Demonstration Program for Template Class PFArray part 3 of 3 Sample Dialogue Enter up to 10 nonnegative integers. Place a negative number at the end. 1 2 3 4 5 -1 You entered the following 1 2 3 4 5 Enter three words I love you You wrote the following I love you I hope you really mean it. Friend Functions Friend functions are used with template classes in the same way that they are used with ordinary classes. The only difference is that you must include a type parameter where appropriate. Self-Test Exercises 12. What do you have to do to make the following function a friend of the template class PFArray in Display void showData PFArray T theObject Displays the data in theObject to the screen. Assumes that is defined for values of type T. THE vector AND basic_string TEMPLATES If you have not yet done so this would be a good time to read Section of Chapter vector 7 which covers the template class vector. Another predefined template class is the basic_string template class. The class basic_ basic_string is a template class that can deal with strings of elements of any type. The string class basic_string char is the class for strings of characters. The class basic_ string double is the class for strings of numbers of type double. The class basic_ string YourClass is the class for strings of objects of the class YourClass whatever that may be . 678 Templates string You have already been using a special case of the basic_string template class. The unadorned name string which we have been using is an alternate name for the class basic_string char . All the member functions you learned for the class string apply and behave similarly for the template class basic_string T . The template class basic_string is defined in the library with header file string and the definition is placed in the std namespace. When using the class basic_string you therefore need the following or something similar near the beginning of your file include .

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
272    19    1    23-11-2024
Đã 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.