Assume we are implementing an abstract data type in C, called
FrobZoid. We have a header file,
frob.h, an implementation file
frob.c, and a program which uses the
ADT in
user.c. Answer the following:
- Where, if anywhere,
would you need
#include "frob.h"?
- Where, if anywhere,
would you need
#include "frob.c"?
- Which files, if any, would need to be compiled?
- What declaration(s) or definition(s) would be needed to define
a function
int make_frob(int m)
which was part of the user interface?
Say where this/these declaration(s) or definition(s) should be placed.
- What happens if the ADT correctly defines
int make_frob(int m) as part of the user interface,
but the code in user.c incorrectly contains the call
make_frob("Hi", 4.5)?
- What declaration(s) or definition(s) would be needed to define
a function
void ruminate_frob(int m) which
was local to the implementation,
and unknown to the user program?
Say where this/these declaration(s) or definition(s) should be placed.
- What declaration(s) or definition(s) would be needed to define
an integer
frob_count which is managed by the implementation,
and available to the user code?
Say where this/these declaration(s) or definition(s) should be placed.
- What declaration(s) or definition(s) would be needed to define
an integer
frob_code_id which is private to the implementation,
and unavailable to the user program?
Say where this/these declaration(s) or definition(s) should be placed.
- What happens if
frob.c defines a function
void bogus(int i) { ... }, user.c makes a call
bogus(2.5), and frob.h does not define the
name bogus at all?