Question: How would you convert the program below in stacks using linked list like it's being asked? header.h class arrayStackType { int s[10]; int max, top;

 How would you convert the program below in stacks using linked
How would you convert the program below in stacks using linked list like it's being asked?
header.h
class arrayStackType
{
int s[10];
int max, top;
public:
arrayStackType();
void push(int);
void pop();
int topStack();
bool isEmptyStack();
void display();
};
header.cpp
#include
#include
#include "header.h"
using namespace std;
arrayStackType::arrayStackType()
{
max=10;
top=-1;
}
void arrayStackType::push(int num)
{
if(top==(max-1))
cout
else
{
top=top+1;
s[top]=num;
}
}
void arrayStackType::pop()
{
if(top==-1)
cout
else
s[top--]='\0';
}
int arrayStackType::topStack()
{
if(top==-1)
{
cout
}
else
{
return s[top];
}
}
bool arrayStackType::isEmptyStack()
{
if(top==-1)
return true;
else
return false;
}
void arrayStackType::display()
{
if (top == 0)
{
cout
}
else
{
cout
for (int t=0 ; t
cout
}
}
main.cpp
#include
#include
#include "header.h"
using namespace std;
int main()
{
arrayStackType stack;
int x,y;
x=4;
y=0;
stack.push(7);
stack.push(x);
stack.push(x+5);
stack.display();
y=stack.topStack();
stack.pop();
stack.display();
stack.push(x+y);
stack.push(y-2);
stack.push(3);
stack.display();
x=stack.topStack();
stack.pop();
stack.display();
cout
cout
cout
while(!stack.isEmptyStack())
{
cout
stack.pop();
}
return 0;
}
Stacks using a Linked List Implementation Part 1 Get the "Stack with Linked List Implementation" (with .h file)to run using the notes from class and your book. Must complete all the "stack operations" (pop, push, isFullStack, etc...) Part 2 After completing the .h from part 1, use page 443 #1 as the .cpp file Thus here is the outline of main' for part 2: #include "linkedstackType.h" int main() linkedStack Type stack; int x, y Show output by the following segment of code: y 0; stack. push(7); stack .push(x); stack, push(x 5); y stack .top stack. pop(); stack .push(x y); stack. push(y 2) stack push(3); x stack .top stack, pop Cout "x x

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 Databases Questions!