Click on stack.cpp to get source.
// File: C++Examples/Stacks/stack.cpp
#include <iostream>
#include "stack.h"
std::ostream& operator<<(std::ostream& os,
const stack& s)
// print the stack; note that this function should work
// independently of the underlying data structure, i.e.,
// it is a generic function
{stack *s2ptr;
int i;
s2ptr = s.clone();
std::cout << "Stack contents: ";
while( !s2ptr->is_empty() )
{i = s2ptr->pop();
std::cout << i << " ";
};
std::cout << " bottom";
delete (s2ptr);
return os;
}// end operator<<