3. +
Data Abstraction
Separationof data logical properties from
data implementation details
Users are given the abstract representation
of data, while the implementation details are
hidden
4. +
Abstract Data Types (ADT)
Structured data types that apply data abstraction
concept – data types that separate the logical
properties from the implementation details
An ADT usually has 3 things:
Type name (name of ADT)
Domain – set of values belonging to the ADT
Set of operations – operations that can be done to the
values in ADT (can be used by others)
5. +
Abstract Data Type - Examples
An ADT that handles time:
Type name : clockType
Domain : the values of a clock in the form of
hours, minutes, and seconds
Set of Operations :
Set the time
Returns the time
Increment the time by one second
Increment the time by one minute
Increment the time by one hour
Compare the two times to see whether they are equal
6. +
Abstract Data Type - Examples
An ADT that handles a list of items:
Type name : listType
Domain : a collection of items, for example an array of 100
integers
Set of Operations :
Check to see whether the list is empty
Check to see whether the list is full
Search the list for a given item
Delete an item from the list
Insert an item into the list
Sort the list
Destroy the list
Print the items of the list
7. +
Implementation of ADT
Obviously,classes class listType {
public:
can be used to bool isEmptyList() const;
define an ADT bool is FullList() const;
int search( int item) const;
void insert(int item);
void remove(int item);
void destroyList();
void printList() const;
listType();
private:
int list[100];
int length;
};
8. +
References:
D.S. Malik (2012). C++ Programming: Program Design
Including Data Structures (5th ed), Thomson Course
Technology.
Chapter 11 – Classes and Data Abstraction