Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Absolute C++ (4th Edition) part 81. 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. . | 808 Standard Template Library Sequential Containers A sequential container arranges its data items into a list so that there is a first element a next element and so forth up to a last element. The sequential container template classes that we have discussed are slist list vector and deque. Pitfall Tip Iterators and Removing Elements Adding or removing an element to or from a container can affect other iterators. In general there is no guarantee that the iterators will be located at the same element after an addition or deletion. Some containers do however guarantee that the iterators will not be moved by additions or deletions except of course if the iterator is located at an element that is removed. Of the template classes we have seen so far list and slist guarantee that their iterators will not be moved by additions or deletions except of course if the iterator is located at an element that is removed. The template classes vector and deque make no such guarantee. Type Definitions in Containers The STL container classes contain type definitions that can be handy when programming with these classes. We have already seen that STL container classes may contain the type names iterator const_iterator reverse_iterator and const_reverse_iterator and hence must contain their type definitions behind the scene . There are typically other type definitions as well. The type value_type is the type of the elements stored in the container and size_type is an unsigned integer type that is the return type for the member function size. For example list int value_type is another name for int. All the template classes we have discussed so far have the defined types value_type and size_type. Self-Test Exercises 7. What is a major difference between vector and list 8. Which of the template classes slist list vector and deque have the member function push_back 9. Which of the template classes slist list vector and deque have random-access iterators 10. Which of the template classes .