Question: implemented stack on the Lab manual : template class Stack { int topindex; T entry [ MAX ] ; / / Maximum size of Stack

implemented stack on the Lab manual :
template
class Stack { int topindex;
T entry[MAX]; // Maximum size of Stack
public:
Stack(){ topindex =0; }
bool Push(T x)
{
if (topindex >= MAX)
return false;
entry[topindex++]= x;
return true;
}
bool Pop()
{
if (topindex <=0)
return 0;
topindex--;
return 1;
}
bool Top(T &x)
{
if (topindex <=0)
return 0;
x = entry[topindex-1];
return 1;
}
bool Empty()
{
return (topindex ==0);
}
};
template
void print(Stack s)
{T item;
while (!s.Empty())
{
s.Top(item);
cout<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!