//Author: Chris ******
//Date: 4/18/2011
//Purpose: Driver file for deque container: stack class
#include <iostream>
#include <deque>
#include <stack>
usingnamespace std;
//Purpose:function to add first 6 integers alternately to front and back of a deque
void AddAlt(deque<int> & D)
{
for (int i = 1; i < 6; i++)
{
D.push_front(i++);
D.push_back(i);
}
}
//Purpose:a template function to display the content of a deque using iterator
template <typename T>
int Display(ostream & out, deque<T> & D)
{
for (deque<int>::iterator it = D.begin(); it != D.end(); it++)
{
cout << *it << " ";
cout << endl;
}
}
//Purpose:a template function to change back value to a specified value
template <typename T>
int changeBack(deque<T> & D, T item)
{
while (!D.empty())
{
cin >> item;
D.pop_back();
D.push_back(item);
cout << D.back() << " ";
}
cout << endl;
}
template <typename T>
int main()
{
int item;
stack<T> stInt;
cout << "Enter item:" << endl;
cin >> item;
AddAlt(item);
for (int i = 0; i < 6; i++)
{
stInt.push(i);
Display(i);
}
stInt.push(item);
changeBack(D, item);
return 0;
}
Always show the errors that you get. If too many, then start by showing what you think are the most relevant ones. Don't make us guess! :-)
Now, my guess, hehe: The linker doesn't find the main() function. That's because the one I see in your code is templated. That one cannot count as the program's main entry point.
I also see problems with your types. Example in line 54 where you call AddAlt(). The function requires that you pass as first (and only) argument a dequeue object, but instead you give it an int(eger).
I know. Like I said, you have problems in your code. Maybe too many to discuss in a single thread. If you remove the template, you need to replace T with a valid data type, like int. After that, you need to correct line 54, and then we shall see what else remains.
And once more, remember to post the errors that you get.