Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle 10g Database Administrator Implementation And Administration

Authors: Gavin Powell, Carol McCullough Dieter

2nd Edition

1418836656, 9781418836658

More Books

Students also viewed these Databases questions