{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

apstack - Last Revised abort changed to exit(1 comments...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
// ******************************************************************* // Last Revised: 8/18/98 // abort() changed to exit(1) // comments updated // // September 1, 1997 -- APCS stack class IMPLEMENTATION // // stack implemented using the APCS vector class // ******************************************************************* / #include "apstack.h" #include <stdlib.h> # const int SDEFAULT_SIZE = 10; // default initial stack size c template <class itemType> apstack<itemType>::apstack( ) : myTop(-1), myElements(SDEFAULT_SIZE) // postcondition: the stack is empty { } template <class itemType> apstack<itemType>::apstack(const apstack<itemType> & s) : myTop(s.myTop), myElements(s.myElements) // postcondition: stack is a copy of s { } template <class itemType> apstack<itemType>::~apstack() // postcondition: stack is destroyed { // vector destructor frees memory } template <class itemType> const apstack<itemType> & apstack<itemType>::operator = (const apstack<itemType> & rhs) // postcondition: normal assignment via copying has been performed { if (this != &rhs) { myTop = rhs.myTop; myElements = rhs.myElements; } return *this; } template <class itemType> bool apstack<itemType>::isEmpty() const // postcondition: returns true if stack is empty, false otherwise
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
{ return myTop == -1; }
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}