Great Deal! Get Instant $25 FREE in Account on First Order + 10% Cashback on Every Order Order Now

instruction inside the zip folder and project pdf file

1 answer below »
instruction inside the zip folder and project pdf file
Answered Same DayDec 03, 2021

Solution

Arun Shankar answered on Dec 06 2021
56 Votes
Stack.cpp
#include "Stack.hpp"
Constructor
Stack::Stack()
{

Nothing to do here.
}
int Stack::top() const
{
return v[v.size()-1];
}
void Stack::push(int ele)
{
v.push_back(ele);
}
int Stack::pop()
{
int top_ele = top();
v.pop_back();
return top_ele;
}
int Stack::size() const
{
return v.size();
}
void Stack::print(std::ostream& o) const
{
for(int i= v.size()-1;i>=0;--i)
o
v[i]
"\n";
}
Stack.hpp
#ifndef STACK_HPP
#define STACK_HPP
#include #include --------------------------------------------------------------------
Class: Stack
Description: An implementation of an integer stack built on top
of the STL vector class
--------------------------------------------------------------------
class Stack {
public:

Default Constructor: The vector does not need to be

initialized, but be sure to include an empty constructor in

your implementation.
Stack();

Peek at the stack top without popping it.
int top() const;

void push(int);
Push a new value onto the stack.
int pop();
Pop the stack top and return it.

Return the number of integers cu
ently on the stack.
int size() const;

Print the stack contents, one per line, in reverse order (so

the stack top is on...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here