i want u to check this main program if it is right? plz
Enum error_code{over flow,under flow,success};
Const int maxstack=100;
Template<class stacktype>
Class stack{
Private:
Stacktype entry [maxstack];
int count;
public:
stack();
error_code push(const stacktype & item);
erroe_code pop();
eror_code top(stacktype &item) const;
bool empty() const;
bool full() const;
void clear();
int size() const;
};
Template<class stacktype>
Error_code stack<stacktype >::push(const stacktype &item)
{if (full())
Return overflow;
Entry[count]=item;
Count++;
Return success;
}
Template<class stacktype>
Error_code stack<stacktype >::top(stacktyp e &item) const
{
if (empty())
Return underflow;
Entry[count-1]=item;
Return success;
}
Template<class stacktype>
Error_code stack<stacktype >::pop( )
{
if (empty())
Return underflow;
Count--;
Return success;
}
Void main()
{stack<int> obj;
Obj.push("john" );
Obj.push("sarah ");
If (obj.push("mala k")!=success )
{
Cout<<"problem" <<endl;
Exit(1);
}
Obj.pop();
Temp="salam";
Obj.top(temp);
Cout<<temp<<end l;
}//end of main
Enum error_code{over flow,under flow,success};
Const int maxstack=100;
Template<class stacktype>
Class stack{
Private:
Stacktype entry [maxstack];
int count;
public:
stack();
error_code push(const stacktype & item);
erroe_code pop();
eror_code top(stacktype &item) const;
bool empty() const;
bool full() const;
void clear();
int size() const;
};
Template<class stacktype>
Error_code stack<stacktype >::push(const stacktype &item)
{if (full())
Return overflow;
Entry[count]=item;
Count++;
Return success;
}
Template<class stacktype>
Error_code stack<stacktype >::top(stacktyp e &item) const
{
if (empty())
Return underflow;
Entry[count-1]=item;
Return success;
}
Template<class stacktype>
Error_code stack<stacktype >::pop( )
{
if (empty())
Return underflow;
Count--;
Return success;
}
Void main()
{stack<int> obj;
Obj.push("john" );
Obj.push("sarah ");
If (obj.push("mala k")!=success )
{
Cout<<"problem" <<endl;
Exit(1);
}
Obj.pop();
Temp="salam";
Obj.top(temp);
Cout<<temp<<end l;
}//end of main
Comment