Question
Write a C++ Stack class template (in Stack.h) which implements a stack. You must implement your own linked list for this. Provide the member functions
Write a C++ Stack class template (in Stack.h) which implements a stack. You must implement your own linked list for this. Provide the member functions empty, top, push, pop, size, as well as a constructor and a destructor. You should also implement a copy constructor and an assignment operator. Use a nested class to define the elements in the linked list.
Take your solution from the previous exercise, and change it to use the new Stack class instead of the STL stack class. Put your main program in RPN.cc.
Solution from previous exercise:
1 //********************** 2 // This C++ program is a calculator which evaluates arithmetic expressions 3 // in "Reverse Polish Notation (RPN) and performs addition, subtraction, and multiplication. 4 // Inputs are recieved from the user. 5 //********************************************************************************* 6 7 #include 8 #include 9 #include 10 #include 11 12 using namespace std; 13 14 int main() { 15 SARDANIS 16 17 18 19 24 25 26 27 28 29 30 31 32 33 34 stack S; string s; int temp1, temp2; bool fail = false; ******************************************************** cout < < "Write an equation (addition +, subtraction, and multiplication * only) in Reverse Polish Notation form. End your equation with a period (.): "; // is the end function call while (cin >> s && s!= "."){ if (s == "+") { if (S.size()
Step by Step Solution
3.34 Rating (148 Votes )
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started