#include<iostream> #define STACK_SIZE 30 class char_stack { public: char_stack(); char pop(); char push( char ch ); char gettop(); int empty(); private: char data[STACK_SIZE]; int top; }; char_stack::char_stack() { top=0; } char char_stack::pop() { if(top>0) { return data[--top]; } else return 0; } char char_stack::push( char ch ) { if(top!=STACK_SIZE) { data[top++]=ch; return ch; } else return 0; } int char_stack::empty() { if(top==0) return 1; else return 0; } char char_stack::gettop() { if(top>0) { return data[top-1]; } else return 0; }