Project4-Q1 - #include<iostream> u using namespace...

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

View Full Document Right Arrow Icon
#include<iostream> # using namespace std; u template<class ItemType> struct NodeType { ItemType info; NodeType* next; }; } template<class ItemType> class Stack { private: NodeType<ItemType>* topPtr; // It points to a singly-linked list public: Stack( ); //Default constructor //Post: Stack is created and empty. Stack(const Stack<ItemType> &anotherItem); //Copy constructor //Implicitly called for pass by value. void operator= (Stack<ItemType>); void MakeEmpty(); //Post: Stack is empty bool IsEmpty( ); //Pre: Stack has been initialized //Post: True is returned if there are no elements in the stack. // False is returned otherwise. bool IsFull( ); //Pre: Stack has been initialized //Post: True is returned if there is no room for another ItemType // on the free store. False is returned otherwise. int length( ); //Post: The number of elements in the stack is returned. void Print( ); //Post: The value of all elements in the stack in the sequence // from the top to bottom has been printed. void Push(ItemType newItem); //Pre: Stack has been initialized and is not full //Post: If stack is full, an exception is thrown. // Otherwise, newItem is at the top of the stack. void Pop(ItemType &item); //Pre: Stack has been initialized and is not empty //Post: If stack is empty, an exception is thrown. // Otherwise, top element has been removed from the stack. // item is a copy of removed element.
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/25/2010 for the course CECS CIS 200 taught by Professor Jieshen during the Winter '08 term at University of Michigan-Dearborn.

Page1 / 4

Project4-Q1 - #include&lt;iostream&gt; u using namespace...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online