Lecture Object oriented programming - Lecture no 07

In this chapter, we look at how to model system dynamics, focusing on two aspects: interactions and behavior. An interaction model shows a set of actors and objects interacting by exchanging messages. A behavior model shows how an object or system changes state in reaction to a series of events. | CSC241: Object Oriented Programming Lecture No 07 Previous Lecture static class member Data member Member function Information hiding Developer side Client side Today’s Lecture Abstract data type (ADT) Container classes Proxy classes Operator overloading 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 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, . | CSC241: Object Oriented Programming Lecture No 07 Previous Lecture static class member Data member Member function Information hiding Developer side Client side Today’s Lecture Abstract data type (ADT) Container classes Proxy classes Operator overloading 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 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 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 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 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 Two important principles Separating interfaces from implementation Hiding implementation from user/client We achieve this by .

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
Đã 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.