Question: Write a C++ linked list based stack program that will read the command and push the value in the text file into stack and pop
Write a C++ linked list based stack program that will read the command and push the value in the text file into stack and pop it into another output file. With the struct below:
typedef struct Node
{
int val;
Node *next;
} Node;
class Stack
{
private:
Node *head;
unsigned int s_size;
public:
Stack();
void push(int a);
int pop();
};
Input example 1:
c (create an empty stack) push 2 push 4 push 6 pop pop pop
Expected 1:
6
4
2
Example 2:
c (create an empty stack) push 1 pop pop
Expected 2:
1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
