home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX08052.H
- // class definitions for phonebook list examples
- //--------------------------------------------------------------
-
- // files in this example:
- // %F,15,EX08051.H%EX08051.H definition of class String
- // EX08052.H this file
- // %F,15,EX08051.CPP%EX08051.CPP member functions of String
- // %F,15,EX08052.CPP%EX08052.CPP member functions of PhoneBk
- // PhoneNum and List
- // %F,15,EX0805.CPP%EX0805.CPP main() program
- //--------------------------------------------------------------
-
- #ifndef PHLIST_H
- #define PHLIST_H
-
- #include "EX08051.H"
-
- //--------------------------------------------------------------
- // definition of a class PhoneNum,
- // each object is a name and phone number
- //--------------------------------------------------------------
- class PhoneNum {
- String name;
- long tel;
- public:
- PhoneNum() {};
- PhoneNum( char* n, long tn ) : name (n), tel(tn) {};
- ~PhoneNum() {};
- void enter ( char* n, long tn );
- void change ( long tn) { tel = tn; };
- long gettel() { return tel; };
- int compare (char* who) { return name.compare (who); };
- void copy( const PhoneNum& entry);
- ostream& print(ostream& os);
- };
-
- //--------------------------------------------------------------
- // Definition of a class List,
- // each object is a container of lists
- //--------------------------------------------------------------
- class List {
- PhoneNum* list;
- int last;
- int current;
- public:
- List(int maxsize = 100); // default size 100
- ~List (); // destructor
- PhoneNum* next(); // iterator
- void gototop(); // reset iterator
- void add(PhoneNum& entry); // add an entry
- void del(); // delete current entry
- };
-
- //--------------------------------------------------------------
- // Definition of a class PhoneBk, each object is a phonebook.
- //--------------------------------------------------------------
- class PhoneBk {
- List list;
- int maxsize; // maximum number of entries
- int numEntry; // number of entries so far
- public:
- PhoneBk (); // default constructor
- PhoneBk ( const PhoneBk& oldbook); // copy constructor
- ~PhoneBk () {}; // destructor
- int insert( char* who, long telnum); // insert or change entry
- int remove( char* who); // remove entry for name
- long lookup(char* who); // look up number for name
- ostream& print(ostream& os); // print the phonebook
- };
-
- //--------------------------------------------------------------
- #endif
- //--------------------------------------------------------------
-