Question: I need help with this code I can't get the code to printout in c++ #include #include Stack.h using namespace std; int main() { Stack

I need help with this code I can't get the code to printout in c++

#include #include "Stack.h" using namespace std; int main() { Stack intStack(20); // stack of 20 ints // Use intStack intStack.push(1); intStack.push(2); intStack.push(3); intStack.push(4); cout << "4? " << intStack.peek() << endl; cout << "4? " << intStack.pop() << endl; cout << "3? " << intStack.peek() << endl; cout << "isEmpty 0? " << intStack.isEmpty() << endl; cout << "3 2 1? "; while (!intStack.isEmpty()) { cout << intStack.pop() << " "; } cout << endl; cout << "isEmpty 1? " << intStack.isEmpty() << endl; return 0; }

/** * Stack.h *Third simple class (1) Queue (2) Set (3) Stack (4)PriorityList *Stack is probably the oldest concept of an abstract datatype * " in March 1988 Bauer received the Computer Pioneer Award for the invention of the stack principle" * origin: wikipedia *This example of stack is a container class that will store any type of variable or class *It has only four methods: * push: adds an element following the last filled element * pop: removes the last filled element and returns it * peek: returns the last filled element * isEmpty: returns true if there are no used vectors */ #ifndef STACK_H_ #define STACK_H_ #include #include #include template class Stack { private: std::vector elements; int topIndex; //index of last filled vector index public: // Constructor that resizes vector and sets topIndex to -1 Stack(int const & max) { } // Add element at the end of the stack [topIndex] // increase topIndex void push(T const& element) { } // Reduce topIndex and return the element[topIndex] T pop() { } //Return element[topIndex] T peek() const { } //If topIndex indicates empty, return true, else false bool isEmpty() const { // return true if empty. } }; // endl class declaration and definition #endif /* STACK_H_ */

/*

Student Name, CIS127, Assignment 11.1

4? 4 4? 4 3? 3 isEmpty 0? 0 3 2 1? 3 2 1 isEmpty 1? 1 Press any key to continue . . . */

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!