April 17, 2015

Homework Help: programming

Posted by Aleen on Saturday, January 14, 2012 at 10:28pm.

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

cout << "\nStack 1:\n ";

cout << "\nStack 2:\n ";
transferStack(stack1, stack2);

cout << "\nStack 1 is unchanged:\n ";

cout << "\n\n** Press any key to continue **\n";

return 0;

template <class Type>
void printStack(linkedStackType<Type>& stack)
Type item;
linkedStackType<Type> tmpStack = stack;

while (stack.isEmptyStack() == false)
item =;
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.


Answer this Question

First Name:
School Subject:

Related Questions

computer science - Algorithm for Binomial Numbers Task Binomial numbers (or ...
C++ Algorithms - Binomial numbers (or binomial coefficients) are important ...
C++ Programming - I have to redo programming exercise 5 of chapter 9 using ...
computer science - ineed help with c++. i am using code blocks and i have a ...
C++ Programming - Design and create a class named Stats that has an array of 12 ...
Fund of programming 1 - Complete the following C++ program. The program should ...
Programing - Write a full program that reads in an arbitrary sequence of ...
programming C++ - Write a program that reads test scores up to 30 into an array...
C++ - Can anyone help me with my c++ program? Its a program I have to write ...
c++ - when i compile the following, many erors appear // include necessary ...