Download - Stack Application

Transcript

Q. creates a class of a stack in c++ and illustrate the stack with a main function.//file name pstack.h// declaration of the class into the header fileifndef _PSTACK_H_#define _PSTACK_H_class pstack{private:enum {MAXSIZE=100};int *item; int top;public:pstack();~pstack();void push(const int);int pop();bool IsEmpty()const;bool IsFull()const;double Eval_postfix(char *postfix);double oper(double,double,char op);bool IsDigit()const;};#endif

//file name pstack.cpp//definition of class pstack#include "pstack.h"#includepstack::pstack(){top=-1;item=new int[100];}pstack::~pstack(){delete []item;}bool pstack::IsEmpty()const{if(top==-1)return true;elsereturn false;}bool pstack::IsFull()const{if(top==MAXSIZE-1)return true;elsereturn false;}void pstack::push(const int x){if(IsFull()){cout