#ifndef _intstack_h_ #define _intstack_h_ #include // Implements a stack of integers. class IntStack { private: // Stack node type. struct StackNode { StackNode(int d, StackNode *n) { data = d; next = n; } int data; StackNode *next; }; // Head of the stack StackNode *head; public: // Must make sure stack is empty at construct. IntStack() { head = NULL; } // Push onto the stack. void push(int i) { head = new StackNode(i, head); } // Remove from the stack. int pop(); // Find out what's on the top. int top() { if(head == NULL) return 0; else return head->data; } // So, are we empty yet? bool isEmpty() { return head == NULL; } // Remove all memory from the stack. void clear(); }; #endif