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 / intstck2.h < prev    next >
C/C++ Source or Header  |  2005-06-16  |  2KB  |  60 lines

  1. //               intstck2.h
  2. //
  3. // Contains the declaration of intStack 
  4. // implemented by containment using class intList
  5. //
  6.  
  7. // Include Files
  8. #include "intlist.h"
  9.  
  10. class intStack {
  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;
  23.     // PRECONDITION:  none
  24.     //
  25.     // POSTCONDITION: returns true if the stack is 
  26.     //                empty and false if not.
  27.  
  28.     bool IsFull() const;
  29.     // PRECONDITION:  none
  30.     //
  31.     // POSTCONDITION: returns true if the stack 
  32.     //                is full and false if not.
  33.  
  34.     bool Push( int elt );
  35.     // PRECONDITION:  elt is to be pushed on the stack.
  36.     //
  37.     // POSTCONDITION: returns true if elt is at the top 
  38.     //                of the stack; returns false if elt 
  39.     //                could not be pushed on the stack.
  40.  
  41.     bool Pop();
  42.     // PRECONDITION:  none
  43.     //
  44.     // POSTCONDITION: returns true if an element was 
  45.     //                removed from the stack; returns 
  46.     //                false if not.
  47.  
  48.     bool Top( int &elt );
  49.     // PRECONDITION:  none
  50.     //
  51.     // POSTCONDITION: returns false if the stack is empty 
  52.     //                and elt is unchanged; otherwise, 
  53.     //                returns true and elt contains the 
  54.     //                integer that is on top of the stack.
  55.  
  56. private:
  57.     intList l;
  58. };
  59.  
  60.