Linked List Stack

Download the file linkedStack.zip. Modify the driver.cpp file by implementing the function called reverseStack() that will reverse the contents from a given stack and place the results back in the original stack. This function only takes a stack variable as parameter. The function can use an additional local temporary stack for processing. The prototype for this function appears as follows:

template

void transferStack(linkedStackType& stack);

Note: Again, you only need to modify the driver.cpp file by adding the necessary code to implement the TODO areas as noted in the comments. The prototype for the function and everything else in the program will remain the same. Review the printStack() function as an example on how to create a while-loop and how use an temporary stack for this function.

Output: The output for the program after the function is implemented should appear as follows:

Stack:

262 115 74 26 34 243 22 734 113 121

Stack Reversed:

121 113 734 22 243 34 26 74 115 262

** Press any key to continue **

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

×
New Download