|
Introduction
Syllabus
Guidelines for labs
Lab sections
Take quiz & check grades
| |
Abstract Data Type implementations in C
a structure of data inaccessible to the user except through a predefined set of
functions...
What do we need?
- user cannot access the data in the ADT directly;
- user cannot modify the functions of the ADT;
- user needs to know the interface so he or she can write programs using the ADT
- user program needs to refer and link to the ADT
- a given program may use more than one object of the same ADT.
- Most likely, user will only have the object code of the ADT
How can we do that?
 | Write the data structures and the functions in a separate file (which may even be
supplied in object form). That takes care of 1 and 2. |
 | Write a header file with function prototypes and declarations for whatever pieces of
data the user is allowed to see and make references. That takes care of 3 and part of 4. |
 | Use a handle (a pointer to each object of the ADT). The user declares the handle to be a
pointer to the desired ADT. The value of the pointer should be set by a constructor
(initialization) function of the ADT. User will keep that particular pointer to refer to
that particular object. If more than one object are needed, just use other handles. That
takes care of 5. |
 | Since you need to put together several program files, you need to instruct the
linker by means of a make file. This takes care of 4. |
|