Deque container assignment

This is my code for an assignment that I am currently working on:
"2a. Write a function to add first 6 integers alternately to front and back of a deque. (in header file)

2b. Write a template function to display the content of a deque using iterator (in header file)

2c. Write a template function to change back value to a specified value using iterator (in header file)

Then write a driver to test the above three template functions."

my problem is that I keep getting error-LNK1120 and LNK2019. I project is also in console, so what could the problem be?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Driver.cpp
#include"deque.h"
#include<deque>
#include<iostream>
using namespace std;
template <typename T>

int main()
{
     //variable declaration
     int item;
     stack<T> s;   
     //getting user input
     cout << "Enter input:" << endl;
     cin >> item;
     ADDItems(item);
     for (int i = 0; i < 6; i++)
     {
          s.push(i);
          //call of display method
          Display(i);
     }
     s.push(item);
     //call of changeback method
     changeBack(d, item);
     return 0;
}

Deque.h
#include<iostream>
#include<deque>
using namespace std;

//function to add item.
void ADDItems()
{
	deque<int> d;
	for (int i = 1; i < 6; i++)
	{
		//deque to push front
		d.push_front(i++);
		//deque to push back
		d.push_back(i);
	} 
}

//template function to display the items
template <typename T>
void Display(ostream & out, deque<T> & d)
{
     for (deque<int>::iterator t = d.begin(); it != d.end(); t++)
     {
          cout << *t << "   ";
         cout << endl;
     }
}

//template function to change back the item.
template <typename T>
void changeBack(deque<T> & d, T item)
{
     //checking if the object is empty
     while (!d.empty())
     {
          cin >> item;
          d.pop_back();
          d.push_back(item);
          cout << d.back() << " ";
     }
     cout << endl;
}
The main() function must be defined as a normal function. It's not allowed to be a function template.
Last edited on
Topic archived. No new replies allowed.