Question
Consider the following Stack class that uses linked list to construct the stack class Node; typedef Node* NodePtr; class Node { public: int number; NodePtr
Consider the following Stack class that uses linked list to construct the stack
class Node; typedef Node* NodePtr;
class Node { public: int number; NodePtr next; Node(){number=0; next=NULL;} Node(int n){number=n; next=NULL;} }; //----------------------------------------
class Stack { private: NodePtr top; int currSize; const int fullSize;
public: //initializes the Stack to an empty Stack (fixed size of 5) Stack() { fullSize= 5; currsize= 0; top=NULL; } //initializes the Stack to an empty Stack and specific maximum size Stack(int maxSize) { fullSize= maxSize; currsize= 0; top= NULL; } int push(int item); //places an item into the stack. Returns -1 if operation is not successful int pop(int& item); //removes an item from the stack. Return -1 if operation is not successful bool empty(); //checks if the stack is empty bool full(); //checks if the stack is full
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started