Question
Please be a original answer and copy and pasted. Here is what I have for the beginning. #include #include using namespace std; //definition of the
Please be a original answer and copy and pasted. Here is what I have for the beginning.
#include
public: void initializeStack(); bool isFullStack() const; bool isEmptyStack() const; void push(const Type&); void pop(); Type top() const; stackType(int = 20); ~stackType(); bool operator==(const stackType
// create objects of type stackType stackType
// insert elements into the stacks cout << " \tInserting elements 5, 10, 15 ... " << "to both the stacks."; for (int i = 5; i < 50; i += 5) { s1.push(i); s2.push(i); } // end for //check and print whether the stacks are equal or not if (s1 == s2) cout << " \tBoth the stacks are equal"; else cout << " \tBoth the stacks are not equal"; // insert one more element into the second stack cout << " \tInserting element 11 to the second stack."; s2.push(11); //check and print whether the stacks are equal or not if (s1 == s2) cout << " \tBoth the stacks are equal"; else cout << " \tBoth the stacks are not equal"; cout << " \t"; system("pause"); return 0; }
a. Add the following operation to the class stackType: void reverseStack(stackType &otherStack); This operation copies the elements of a stack in reverse order onto another stack. Consider the following statements: stackType stack1; stackType stack2; The statement stack1.reverseStack(stack2); copies the elements of stack1 onto stack2 in reverse order. That is, the top element ofstack1 is the bottom element ofstack2, and so on. The old contents of stack2 are destroyed and stack1 is unchanged. b. Write the definition of the function template to implement the operation reverseStack.
Step by Step Solution
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