Tom Kelliher, CS23
Feb. 23, 1996
Fields:
Design goals:
struct committeeList { unsigned short committeeCode; struct committeeList* next; }; struct employeeRecord { char firstName[20]; char lastName[30]; unsigned char deptCode; long salary; struct employeeRecord* manager; struct committeList* committees; struct employeeRecord* next; };
ADT employee list operations?
Create:
struct employeeRecord* employees = NULL;
Where is the ``wall?''
What information is hidden?
Skeleton of main module:
#include "list.h" ... main(){ create(); addEmployee(...); ... }
Skeleton of list.h:
/* definitions for committeeList, employeeRecord structs */ int create(void); int destroy(void); int addEmployee(<formals>); ...
Skeleton of list.c:
#include "list.h" static struct employeeRecord* employees; /* definitions for ADT operations */
Three files:
Compiling:
cc -o database main.c list.c
Create:
EmployeeList employees; // call constructor
Where is the ``wall?''
What information is hidden?
Skeleton of main module:
#include "list.h" ... main(){ EmployeeList employees; employees.addEmployee(...); ... }
Skeleton of list.h:
// definitions for committeeList, employeeRecord structs class EmployeeList { public: EmployeeList(void); // constructor ~EmployeeList(void); // destructor int addEmployee(<formals>); ... private: employeeRecord* list; ... other hidden members or methods };
Skeleton of list.cc:
#include "list.h" EmployeeList::EmployeeList(void) { } EmployeeList::~EmployeeList(void) { } EmployeeList::addEmployee(<formals>) { }
Compiling:
g++ -o database main.cc list.cc
struct foo { int this; char that; }; foo bar;
class Foo { public: foo(); ~foo(); char moreFoo(int, int); private: int allMyFoo[FOO_AMOUNT]; int hiddenFoo(int); }; Foo bar;
className::methodName(<formals>) { }