A Stack element would be something like
Code:
template<class T> struct StackNode{
struct StackNode* next;
T element;
}
and to print it in both normal and reverse order
Code:
//normal
template<class T> void print_node(struct StackNode<T> *node){
if(node==NULL)
return;
//print element. maybe std::cout<<node->element;
print_node(node->next);
}
//reverse
template<class T> void print_node(struct StackNode<T> *node){
if(node==NULL)
return;
print_node(node->next);
//print element. maybe std::cout<<node->element;
}
It very simple as you can see...