home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX0601.H
- // the prototype implementation of a phone book class
- // class definition for phonebook example.
-
- // files in this example:
- // EX0601.H this file -- definition of the class PhoneBk
- // %F,15,EX06021.CPP%EX06021.CPP member functions of the class PhoneBk
- // %F,15,EX06022.CPP%EX06022.CPP small application main() to exercise this class
-
- #include <iostream.h> // for stream I/O
- #include <string.h> // for string manipulation
-
- // A typedef is used for strings rather than a string class
- // each name can be up to 19 characters plus a terminator
-
- typedef char String[20];
-
- // Definition of a class PhoneBk, each object is a phonebook.
- // Implentation has fixed sized arrays for names and phone numbers
- // and an integer counter for the number of entries.
- // This is a variation of the phonebook example of Chapter 5.
- // 2 Constructors and a destructor have been added.
-
- class PhoneBk {
- String names[100]; // room for 100 names
- long tel[100]; // room for 100 phone numbers
- int numEntry; // number of entries so far
- public:
- PhoneBk () { numEntry = 0; }; // 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
- };
-
-