programming
posted by Aleen .
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 whileloop 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;
}
Respond to this Question
Similar Questions

computer science
Algorithm for Binomial Numbers Task Binomial numbers (or binomial coefficients) are important positive integers that arise frequently in computing and mathematics. A function to compute binomial coefficients will have two inputs: n … 
C++ Programming
I have to redo programming exercise 5 of chapter 9 using dynamic arrays. but I have the information but I don't know how to use it in a dynamic arrays please help. //Chapter 9: Programming Exercise 5 #include <iostream> #include … 
C++ Algorithms
Binomial numbers (or binomial coefficients) are important positive integers that arise frequently in computing and mathematics. A function to compute binomial coefficients will have two inputs: n and k. The corresponding coefficient … 
computer science
ineed help with c++. i am using code blocks and i have a problem with the compiler. when I run this code ¡é # include <iostream> using namespace std; int main() { cout<<"Hello World!"<<endl return(0); } this message … 
C++ Programming
Design and create a class named Stats that has an array of 12 doubles as one of its member variables. The values in the array should be set by making 12 calls to a public member function named setValue that accepts two arguments, an … 
programming C++
Write a program that reads test scores up to 30 into an array. sentinel will stop when 1 is entered. Write functions that: 1. read the scores into arrays 2. computes the distribution based on whether they are As, Bs and so on 3. find … 
Fund of programming 1
Complete the following C++ program. The program should compute and output the Celsius value corresponding to the given Fahrenheit value. //************************************************ // Celsius program // This program outputs … 
Programing
Write a full program that reads in an arbitrary sequence of integers from the standard input, and writes them to the standard output in sorted order and with all duplicates removed. You may assume the input contains at most 100 integers … 
itc c++
can any one please dry run this code #include<iostream> using namespace std; int main() { intnum,factor=1,temp; cout<<"Enter any integer value"<<endl; cin>>num; //number given by the user is 10123. temp=num; … 
C++
I am trying to create a program that displays shipping charges for two region codes. The region code has to have exactly 3 characters (the letter A or B followed by two numbers). Display a message if invalid region code is entered. …