The code isn't displaying and then reversing entered numbers.
reverse.cpp
//
//
#include <cstdlib>
#include <iostream>
#include "linkedStack.h"
using namespace std;
int main()
{
linkedStackType<int> stack1;
linkedStackType<int> stack2;
cout << "";
cout << "output your name\n\n";
int number = 0;
// AUSE LINKED STACKS
//
cout << "Enter first number 1 to be stored in Stack 1: ";
cin >> number;
cout << "Enter first number 2 to be stored in Stack 1: ";
cin >> number;
cout << "Enter first number 3 to be stored in Stack 1: ";
cin >> number;
//
// PUSH NUMBERS ON STACK
stack1.push(number);
//
// REVERSE NUMBERS IN STACK 1
// AND SAVE THEM IN STACK 2;
stack1.reverseStack(stack2);
cout << "\n\nNumbers in Stack 1: ";
while (!stack1.isEmptyStack())
{
cout<<stack1.top()<<" ";
stack1.pop();
}
cout << endl;
cout << "Numbers in Stack 2, which is Stack 1 in reverse order: ";
while (!stack2.isEmptyStack())
{
// OUTPUT NUMBERS IN STACK 2
cout<<stack2.top()<<" ";
stack2.pop();
}
cout << endl;
cout << "\n\n\n\n";
system("pause");
return 0;
}
/Header file: stackADT.h
#ifndef H_StackADT
#define H_StackADT
//*************************************************************
/
//*************************************************************
template <class Type>
class stackADT
{
public:
virtual void initializeStack() = 0;
//Method to initialize the stack to an empty state.
//Postcondition: Stack is empty.
virtual bool isEmptyStack() const = 0;
//Function to determine whether the stack is empty.
//Postcondition: Returns true if the stack is empty,
// otherwise returns false.
virtual bool isFullStack() const = 0;
//Function to determine whether the stack is full.
//Postcondition: Returns true if the stack is full,
// otherwise returns false.
virtual void push(const Type& newItem) = 0;
//Function to add newItem to the stack.
//Precondition: The stack exists and is not full.
//Postcondition: The stack is changed and newItem is added
// to the top of the stack.
virtual Type top() const = 0;
//Function to return the top element of the stack.
//Precondition: The stack exists and is not empty.
//Postcondition: If the stack is empty, the program
// terminates; otherwise, the top element of the stack
// is returned.
virtual void pop() = 0;
//Function to remove the top element of the stack.
//Precondition: The stack exists and is not empty.
//Postcondition: The stack is changed and the top element
// is removed from the stack.
};
#endif
/Header file: stackADT.h
#ifndef H_StackADT
#define H_StackADT
//*************************************************************
//*************************************************************
template <class Type>
class stackADT
{
public:
virtual void initializeStack() = 0;
//Method to initialize the stack to an empty state.
//Postcondition: Stack is empty.
virtual bool isEmptyStack() const = 0;
//Function to determine whether the stack is empty.
//Postcondition: Returns true if the stack is empty,
// otherwise returns false.
virtual bool isFullStack() const = 0;
//Function to determine whether the stack is full.
//Postcondition: Returns true if the stack is full,
// otherwise returns false.
virtual void push(const Type& newItem) = 0;
//Function to add newItem to the stack.
//Precondition: The stack exists and is not full.
//Postcondition: The stack is changed and newItem is added
// to the top of the stack.
virtual Type top() const = 0;
//Function to return the top element of the stack.
//Precondition: The stack exists and is not empty.
//Postcondition: If the stack is empty, the program
// terminates; otherwise, the top element of the stack
// is returned.
virtual void pop() = 0;
//Function to remove the top element of the stack.
//Precondition: The stack exists and is not empty.
//Postcondition: The stack is changed and the top element
// is removed from the stack.
};
#endif