home *** CD-ROM | disk | FTP | other *** search
/ Microsoftware Monthly 19…2 Programming Power Tools / MASO9512.ISO / cpptutor / cpptutor.arj / EXAMPLES / EX08063.H < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-27  |  2.0 KB  |  51 lines

  1. //  \EXAMPLES\EX08063.H
  2. //  definition of classes List, and ListIter
  3. //--------------------------------------------------------------
  4.  
  5. //  files in this example:
  6. // %F,15,EX08061.H%EX08061.H       definition of class String
  7. // %F,15,EX08062.H%EX08062.H       definition of class PhoneNum
  8. // EX08063.H       this file
  9. // %F,15,EX08064.H%EX08064.H       definition of class PhoneBk
  10. // %F,15,EX08061.CPP%EX08061.CPP     member functions of class String
  11. // %F,15,EX08062.CPP%EX08062.CPP     member functions of the class PhoneNum
  12. // %F,15,EX08063.CPP%EX08063.CPP     member functions List and ListIter
  13. // %F,15,EX08064.CPP%EX08064.CPP     member functions of class PhoneBk
  14. // %F,15,EX0806.CPP%EX0806.CPP    main to exercise PhoneBk class
  15. //--------------------------------------------------------------
  16. #ifndef INCLPHL_H
  17. #define INCLPHL_H
  18.  
  19. //--------------------------------------------------------------
  20. #include "EX08062.H"
  21.  
  22. //--------------------------------------------------------------
  23. // Definition of class List
  24. //--------------------------------------------------------------
  25.  
  26. class List {
  27.   PhoneNum* list;                   // list of PhoneNum objects
  28.   int last;                         // last occupied spot in list
  29.   friend class ListIter;            // iterator class
  30. public:
  31.   List(int maxsize = 100);          // default size 100
  32.   ~List ();                         // destructor
  33.   void add(PhoneNum& entry);        // add an entry
  34.   void del(PhoneNum* entry);        // delete entry
  35. };
  36.  
  37. //--------------------------------------------------------------
  38. // Definition of a class ListIter, iterator for class List
  39. //--------------------------------------------------------------
  40.  
  41. class ListIter {
  42.   int current;                      // index current entry
  43. public:
  44.   ListIter() : current(-1) {};      // constructor
  45.   ~ListIter() {};                   // destructor
  46.   PhoneNum* next( const List& list);// iterator function
  47. };
  48.  
  49. //--------------------------------------------------------------
  50. #endif
  51.