Question
//Stack.h #ifndef STACK_H #define STACK_H #include LL.h template class Stack { private: // using a LinkedList as the storage for this Stack LinkedList & data;
//Stack.h
#ifndef STACK_H
#define STACK_H
#include "LL.h"
template
private:
// using a LinkedList as the storage for this Stack
LinkedList
public:
// constructor
Stack ():
data {*(new LinkedList
// accessors -----------------------------------------------------
// returns a copy of the pointer to the local data variable
LinkedList
return data;
}
void printStack() const {
data.printList();
}
// return first element of stack without removing
T peek() const {
// CODE HERE
return T {}; // PLACEHOLDER FOR COMPILING
}
// mutators ------------------------------------------------------
// remove the element off the top of the stack and return it. If
// the stack is empty, return the empty constructor for type T.
T pop(){
// CODE HERE
return T {}; // PLACEHOLDER FOR COMPILING
}
// push item thing of type T onto the stack
void push(T thing) {
// CODE HERE
}
};
#endif
-----------------
//Stack.cpp
#include "Stack.h"
/* empty because Stack is a template class */
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