Abstract Data Type
When one search for a tool, he needn’t know how the tool have been implemented but only to know how to use and what he can get.
ADT is a package of the declarations of a data type and the operations that are meaningful to it.
We encapsulate the data type and the operations and hide them from the user.
That is to say, ADTs are implementation independent.
ADT consists:
- Definition of values
- Definition
- Condition (optional)
- Definition of operations
- Header (type and name of the function)
- Precondition (opt.)
- Postcondition
Data Abstraction
Data abstraction is an important method is program design.
Algorithms can be designed in terms of the ADT.
(There should be a table of phase to solve a problem)
Miscellaneous
Passing Arguments
- Pass by Value
int Square(int x);
- Pass by Reference
int Square(int *x);
// actually, this one may create a new pointer variable
or
int Square(int &x);
Question: the security of const &
?