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 class Stack {

private:

// using a LinkedList as the storage for this Stack

LinkedList & data;

public:

// constructor

Stack ():

data {*(new LinkedList())} {}

// accessors -----------------------------------------------------

// returns a copy of the pointer to the local data variable

LinkedList& getData() const {

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

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!