home *** CD-ROM | disk | FTP | other *** search
/ C by Discovery (4th Edition) / C_By_Discovery_4th_Edition.tar / C_By_Discovery_4th_Edition / _DISK_ / ch12 / intstack.h < prev    next >
C/C++ Source or Header  |  2005-06-16  |  2KB  |  57 lines

  1. //               intstack.h
  2. //
  3. // Contains the declaration of a stack 
  4. // privately derived from class intList
  5.  
  6. // Include Files
  7. #include "intlist.h"
  8.  
  9. class intStack: private intList                      // Note 1
  10. {
  11. public:
  12.     intStack();
  13.     // PRECONDITION:  none.
  14.     //
  15.     // POSTCONDITION: an empty stack is created.
  16.  
  17.     ~intStack();
  18.     // PRECONDITION:  none.
  19.     //
  20.     // POSTCONDITION: the stack is destroyed.
  21.  
  22.     bool IsEmpty() const;                            // Note 2
  23.     // PRECONDITION:  none.
  24.     //
  25.     // POSTCONDITION: returns true if the stack is 
  26.     //                empty and false if not.
  27.  
  28.     bool IsFull() const;                             // Note 2
  29.     // PRECONDITION:  none.
  30.     //
  31.     // POSTCONDITION: returns true if the stack 
  32.     //                is full and false if not.
  33.  
  34.     bool Push( int elt );                            // Note 3
  35.     // PRECONDITION:  elt is to be pushed on the stack.
  36.     //
  37.     // POSTCONDITION: returns true if elt was pushed onto the 
  38.     //                top of the stack; returns false if elt 
  39.     //                could not be pushed on the stack.
  40.  
  41.     bool Pop();                                      // Note 4
  42.     // PRECONDITION:  none.
  43.     // POSTCONDITION: returns true if an element was 
  44.     //                removed from the stack; returns 
  45.     //                false if not.
  46.  
  47.     bool Top( int &elt );                            // Note 5
  48.     // PRECONDITION:  none.
  49.     //
  50.     // POSTCONDITION: returns false if the stack is empty 
  51.     //                and elt is unchanged; otherwise, 
  52.     //                returns true and elt contains the 
  53.     //                integer that is on top of the stack.
  54.  
  55. private:
  56.     // Private data members omitted.
  57. };