TAILIEUCHUNG - Object Oriented Programming (7)

CSC241: Object Oriented Programming. Lecture No 07. 1 Previous Lecture.•. static class member. – Data member. – Member function.•. Information hiding. Developer. Client side. side. . Distance pp a . Distance a 2 Today’s Lecture.•. Abstract data type (ADT).•. Container classes.•. Proxy classes.•. Operator overloading. 3 Abstract data type.•. Consider built-in type int.•. Most people associate it with an integer in. mathematics.•. Actually, int is an abstract representation of an. integer.•. ints are fixed in size (32-bits).•. if result is out of range. – “Overflow” error occurs. – "quietly" produce an incorrect result.•. Mathematical integers do not have this problem 4 Cont•. Built-in data types are only approximations or. imperfect models of real-world concepts.•. Types like int, double, char and others are all. examples of abstract data types.•. An abstract data types captures two concepts. – Data representation. – Operations that can be perform on that data.•. For example. – int contain integers values. – Operations: add, subtract, multiply, division 5 ADT in C++.•. In C++, the programmer uses classes to. implement abstract data types and their services.•. For example, to implement a array ADT. – subscript range checking. – an arbitrary range of subscripts instead of having to. start with 0. – array assignment. – array comparison. – array input/output 6 Container classes – real world.•. In real life, we use containers all the time.•. For example. – pages in your book come inside a cover or binding. – you might store any number of items in containers in. your garage.•. Without container it is inconvenient to work with. many objects. – Imagine trying to read a book that didn’t have any sort. of binding. – Eat cereal that didn’t come in a box without using a. bowl 7 Container classes – C++.•. Container classes designed to hold collections of. instance of other classes.•. Arrays, stacks, queues, trees and linked lists are. examples of container classes. 8 Two important . Separating interfaces from. . Hiding implementation from user/ achieve this by defining a class in and implementation of class function in cpp source file. 9 Proxy class.•. Proxy class allows to hide the private data. and other functions of a class from clients.•. Providing client with proxy class enables it to. use your class services with know. implementation detail of your . Interface class Client class. class. Go to. program 10 Static h class. Contains. definition of. Implementation . class. . Contains Contains class. Contains class. definition of definition of. definition of. member function interface class. interface

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.