home *** CD-ROM | disk | FTP | other *** search
- // \EXAMPLES\EX0501.H
- // the prototype implementation of a phone book class
- // class definition for phonebook example.
-
- //--------------------------------------------------------------
- // files in this example:
- // EX0501.H this file -- definition of the class PhoneBk
- // %F,15,EX05011.CPP%EX05011.CPP member functions of the class PhoneBk
- // %F,15,EX05012.CPP%EX05012.CPP main() to exercise this PhoneBk
- //--------------------------------------------------------------
-
- #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.
- // This program has fixed-sized arrays for names and phone
- // numbers, and an integer counter for the number of entries.
- // This is a simple implementation of this class
- // It does not have a constructor or destructor as these topics
- // are not described in Teach Me C++ until Chapter 6.
-
- class PhoneBk {
- String names[100]; // room for 100 names
- long tel[100]; // room for 100 numbers
- int numEntry; // number of entries so far
- public:
- void init() { numEntry = 0; }; // replace with constructor
- 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
- };
-
-