#include <stack.h>
Public Member Functions | |
Stack () | |
Stack (const Stack &) throw ( bad_alloc ) | |
~Stack () | |
bool | empty () const |
unsigned | size () const |
void | clear () |
void | push (const T &) throw ( bad_alloc ) |
T | pop () throw ( StackEmpty ) |
T & | top () const throw ( StackEmpty ) |
const Stack< T > & | operator= (const Stack< T > &) throw ( bad_alloc ) |
Copy constructor.
s | the stack to be copied |
bad_alloc | if memory for the new stack cannot be allocated |
bool Stack< T >::empty | ( | ) | const |
Returns true if this stack is empty; otherwise, returns false.
unsigned Stack< T >::size | ( | ) | const |
Returns the number of items in the stack.
void Stack< T >::clear | ( | ) |
Clears the stack by deleting each item.
void Stack< T >::push | ( | const T & | item | ) | throw ( bad_alloc ) |
Pushes the item onto this stack.
item | the item to be added to the top of this stack |
bad_alloc | if memory for the new item cannot be allocated |
T Stack< T >::pop | ( | ) | throw ( StackEmpty ) |
Pops (i.e., removes) the item on the top of the stack.
StackEmpty | if the stack is empty |
T & Stack< T >::top | ( | ) | const throw ( StackEmpty ) |
Returns a reference to the item on the top of the stack.
StackEmpty | if the stack is empty |
const Stack< T > & Stack< T >::operator= | ( | const Stack< T > & | s | ) | throw ( bad_alloc ) |
Overloads the memberwise copy operator. Returns a reference to the copied stack for cascaded assignments (i.e., s1 = s2 = s3).
s | the stack to be copied |
bad_alloc | if memory for the new stack cannot be allocated |