// A stack class is defined here with a private internal storage // and public functions that can manipulate it. // include this file in any program that needs a stack of characters // After page 139 of C++ for Pascal Programmers by Ira Pohl #define MAX_LEN 255 struct stack{ private: char s[MAX_LEN]; int top_at; const static int EMPTY=-1; const static int FULL= MAX_LEN-1; public: void make_new(void) { top_at=EMPTY; } void push(char c) { top_at++; s[top_at]=c; } char pop(void) { return ( s[top_at--]); } char top(void) { return (s[top_at]); } bool empty(void) { return (top_at==EMPTY); } bool full(void) { return (top_at== FULL); } stack(void){make_new();} //auto initialization ~stack(void){while(!empty())pop();} // automatic destruction };