TAILIEUCHUNG - Absolute C++ (4th Edition) part 80

Absolute C++ (4th Edition) part 80. 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. . | 798 Standard Template Library Note that the names forward iterator bidirectional iterator and random-access iterator refer to kinds of iterators not type names. An actual type name would be something like std vector int iterator which in this case happens to be a random-access iterator. Kinds of Iterator Different containers have different kinds of iterators. The following are the main kinds of iterators. Forward iterators works on the iterator. Bidirectionaliterators Both and work on the iterator. Random-access iterators and random access all work with the iterator. Self-Test Exercises 4. Suppose the vector v contains the letters A B C and D in that order. What is the output of the following code using std vector char iterator iterator i i cout i 2 i cout i 2 cout i 2 CONSTANT AND MUTABLE ITERATORS The categories of forward iterator bidirectional iterator and random-access iterator each subdivide into two categories constant and mutable depending on how the constant dereferencing operator behaves with the iterator. With a constant iterator the derefer- iterator encing operator produces a read-only version of the element. With a constant iterator p you can use p to assign it to a variable or output it to the screen for example but you cannot change the element in the container by for example assigning to p. With mutable a mutable iterator p p can be assigned a value and that will change the correspond- iterator ing element in the container. Phrased another way with a mutable iterator p p returns an lvalue. The vector iterators are mutable as shown by the following lines from Display cout Setting entries to 0 n for p p p p 0 Iterators 799 If a container has only constant iterators you cannot obtain a mutable iterator for the container. However if a container has mutable iterators and you want a constant iterator for the container you can have it. You might want a constant iterator as a kind of error checking device if you .

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.