Question: This program uses a dynamic stack template that creates a dynamic stack of any data type. Your task is to write the coding for the
This program uses a dynamic stack template that creates a dynamic stack of any data type. Your task is to write the coding for the push member function. When and if they are given, please use the program's existing constructs and variables.
#ifndef DYN_STACK_HPP
#define DYN_STACK_HPP
// DynStack template
template
class DynStack
{
private:
struct StackNode
{
T value;
StackNode *next;
};
StackNode *top;
public:
DynStack() {top = nullptr; }
void push(T); //This is the one you will write
void pop(T &);
bool isEmpty();
};
// Member function push pushes the argument onto the stack.
// YOU CODE THIS FUNCTION BELOW
// ...
//***************************************************
// Member function pop pops the value at the top
// of the stack off, and copies it into the variable
// passed as an argument.
//***************************************************
YOUR CODE STARTS HERE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
