TAILIEUCHUNG - Lecture Data structures and other objects using C++ - Chapter 3: Container classes

This lecture presents container classes using an example: the bag class. Before this lecture, students should know about these items: How to implement simple classes, such as those in chapter 2, how to separate the class into a header file and an implementation file. | A container class is a data type that is capable of holding a collection of items. In C++, container classes can be implemented as a class, along with member functions to add, remove, and examine items. Container Classes Data Structures and Other Objects Using C++ This lecture introduces container classes from Chapter 3. Before this lecture, students should know about these items: 1. How to implement simple classes, such as those in Chapter 2. 2. How to separate the class into a header file and an implementation file. This lecture presents container classes using an example: the bag class. After this lecture, it would be a good idea to give further coverage of some issues from Section . In particular, you should cover the use of the typedef in the bag implementation, and the += and + operators, which are not covered in this presentation. Bags For the first example, think about a bag. Start by thinking about a bag -- a gym bag, a grocery bag, whatever your favorite bag is. Bags For the first example, think about a bag. Inside the bag are some numbers. Inside the bag, is a collection of numbers, such as the collection of two fours and an eight shown here. Initial State of a Bag When you first begin to use a bag, the bag will be empty. We count on this to be the initial state of any bag that we use. THIS BAG IS EMPTY. This bag will be our first example of a container class, which is a class where each object can contain a collection of items (such as numbers). One of the important facets of a container class is that each object begins in a known configuration. In the case of a bag, we will count on each bag being initially empty. This is called the initial state of a bag. Inserting Numbers into a Bag Numbers may be inserted into a bag. I AM PUTTING THE NUMBER 4 INTO THE BAG. We will use a fixed collection of operations to manipulate bags. One of the simplest operations that we permit is the action of inserting a new number into a bag. Inserting Numbers into a Bag .

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.