Tom Kelliher, CS18
Apr. 24, 1996
Fields:
Design goals:
struct committeeList { unsigned short committeeCode; struct committeeList* next; }; struct employeeRecord { char* firstName; char* lastName; 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:
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>) { }
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>) { }
ClassName::ClassName(const ClassName&)