home *** CD-ROM | disk | FTP | other *** search
/ The Devil's Doorknob BBS Capture (1996-2003) / devilsdoorknobbbscapture1996-2003.iso / Dloads / OTHERUTI / TCPP30-1.ZIP / CLASSSRC.ZIP / STACK.CPP < prev    next >
C/C++ Source or Header  |  1992-02-18  |  1KB  |  38 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  STACK.CPP                                                             */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991                                  */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( __STACK_H )
  11. #include <Stack.h>
  12. #endif    // __STACK_H
  13.  
  14. #ifndef __IOSTREAM_H
  15. #include <iostream.h>
  16. #endif
  17.  
  18. void Stack::push( Object& toPush )
  19. {
  20.     theStack.add( toPush );
  21.     itemsInContainer++;
  22. }
  23.  
  24. Object& Stack::pop()
  25. {
  26.     Object& temp = theStack.peekHead();
  27.     theStack.detach( temp );
  28.     if( temp != NOOBJECT )
  29.         itemsInContainer--;
  30.     return temp;
  31. }
  32.  
  33. ContainerIterator& Stack::initIterator() const
  34. {
  35.     return *( (ContainerIterator *)new ListIterator( this->theStack ) );
  36. }
  37.  
  38.