I need help in the TODO section.
/**
* Driver.cpp - This file contains the driver code to test the
* linkedStackType class implementation
*
*/
#include <iostream>
#include "linkedStack.h"
using namespace std;
template <class Type>
void printStack(linkedStackType<Type>& stack);
template <class Type>
void transferStack(linkedStackType<Type>& stack1,
linkedStackType<Type>& stack2);
int main(int argc, char *argv)
{
// Declare stack variables
linkedStackType<int> stack1;
linkedStackType<int> stack2;
// Add some data to stack 1
stack1.push(21);
stack1.push(13);
stack1.push(43);
stack1.push(15);
stack1.push(62);
stack1.push(74);
cout << "\nStack 1:\n ";
printStack(stack1);
cout << "\nStack 2:\n ";
transferStack(stack1, stack2);
printStack(stack2);
cout << "\nStack 1 is unchanged:\n ";
printStack(stack1);
cout << "\n\n** Press any key to continue **\n";
getchar();
return 0;
}
template <class Type>
void printStack(linkedStackType<Type>& stack)
{
Type item;
linkedStackType<Type> tmpStack = stack;
while (stack.isEmptyStack() == false)
{
item = stack.top();
stack.pop();
cout << item << " ";
}
stack = tmpStack;
}
template <class Type>
void transferStack(linkedStackType<Type>& stack1,
linkedStackType<Type>& stack2)
{
// TODO: implement the transferStack() function so that the items
// found in stack1 are placed in the same order into stack2.
//
// Suggestions:
// 1. Create a Type item variable and a temporary stack like
// those found in the printStack() function, but do not
// initialize the temporary stack.
//
// 2. Create a while-loop to walk through the items in stack1.
// Place each of these items on the temporary stack using the
// push() method.
//
// 3. Create a second loop to walk through the temporary stack and
// place each item on stack2.
//
// 4. Finally, set stack1 equal to stack2 so that stack1 will
// remain unchanged.
return;
}