Error in classic Bank Teller simulation program? (Had to write original Queue & QueueNode classes)

Hi guys,

I'll forewarn you, it is my first time posting on this site so If I do not adhere to proper etiquette, let me know so I can make future adjustments.

Anyhow, I have a program due Wednesday that is along the lines of the classic Bank Teller simulation using Queue's.

Unlike most of these programs, I have to integrate my own Queue, QueueNode, Teller, and Customer classes. I have attached all of these headers below plus the main file.

Now the error:
While I'm sure there are other issues with the code, it will not let me create a new customerQueue (of Queue type) object as such:

Queue<Customer> customerQueue;

The error it is giving me is:

1
2
no matching constructor for initialization of 
 'Queue<Customer>'


Here is my code:

Queue.h:

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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
 * Queue2.h
 *
 *  Created on: Feb 16, 2014
 *      Author: grantmcgovern
 */

#ifndef QUEUE2_H_
#define QUEUE2_H_

#include <iostream>
#include "Teller.h"
#include "Queue.h"
#include "Customer.h"
#include "QueueNode.h"

template <typename T>
class Queue
{
private:
	const static int Q_SIZE = 10;
	QueueNode<T>*front;												// pointer to front of Queue
	QueueNode<T>*rear;												// pointer to rear of Queue
	int count;													// current number of items in Queue
	const int qsize;											// maximum number of items in Queue
	// preemptive definitions to prevent public copying
	Queue(T C)
	{
		qsize = 0;
		rear = NULL;
		front = NULL;
		count = 0;
	}
	Queue & operator=(const T & q) {return *this;};

public:

	~Queue()
	{
		QueueNode<T> * temp;						// create temporary address store
		while(front != (void *) 0)			// while the queue is not empty
		{
			temp = front;
			front =front->next;			// advance the front object to the next
			delete temp;					// delete the temporary data
		}
	}
	bool isempty() const
	{
		return count == 0;
	}

	bool isfull() const
	{
		return count == qsize;
	}

	int queuecount() const
	{
		return count;
	}

	bool enqueue(const T &data)  	// add item to end
	{
		if(isfull())						// if queue is full halt queuing
			return false;
		QueueNode<T> *add = new QueueNode<T>;				// create node
		add->customer = data;					// set node pointers
		add->next = (void *) 0;				// or nullptr;
		count++;
		if (front == (void *) 0)			// if queue is empty,
			front = add;					// place item at front
		else
			rear->next = add;				// else place at rear
		rear = add;							// have rear point to new node
		return true;
	}

	bool dequeue(T &data)			// remove item from front
	{
		if(front == (void *) 0)				// front node is empty, queue is empty
			return false;

		data = front->customer;					// set data to first item in queue
		count--;							// decrement item count
		QueueNode<T>* temp = front; 				// save location of first item
		front = front->next; 				// reset front to next item
		delete temp;						// delete former first item

		if (count == 0)						// if the queue is now empty set rear to point to nothing
			rear = (void *)0;

		return true;
	}
};


#endif /* QUEUE_H_ */




QueueNode.h:


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
/*
 * QueueNode.h
 *
 *  Created on: Feb 16, 2014
 *      Author: grantmcgovern
 */

#ifndef QUEUENODE_H_
#define QUEUENODE_H_

#include <iostream>
#include "Queue.h"
#include "Customer.h"

using namespace std;
class Customer;
template<class T>
class Queue;

template<class T>
class QueueNode
{
private:
	T customer;
	QueueNode *next;

public:
	QueueNode(T C)
	{
		C = customer;
		next = NULL;
	}
	friend class Queue<T>;
	friend class Customer;
};

#endif /* QUEUENODE_H_ */ 



Customer.h:


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
/*
 * Customer.h
 *
 *  Created on: Feb 16, 2014
 *      Author: grantmcgovern
 */

#ifndef CUSTOMER_H_
#define CUSTOMER_H_

#include <iostream>
#include "QueueNode.h"
#include "Queue.h"
#include "Teller.h"
#include <cstdlib>

using namespace std;

class Customer
{
private:
	int serviceTime;
	int arrivalTime;
public:
	Customer()
	{
		serviceTime = 0;
		arrivalTime = 0;
	}
	/*
	void setServiceTime()
	{
		serviceTime = 1 + rand() % maxService;
	}
	*/


	Customer(int arrival, int maxService)
	{
		arrivalTime = arrival;
		serviceTime = 1 + rand() % maxService;
	}

	int getServiceTime()
	{
		return serviceTime;
	}
	bool isDone()
	{
		return (serviceTime-- <= 0);
	}

	int getArrivalTime()
	{
		return arrivalTime;
	}
};

#endif /* CUSTOMER_H_ */ 



Teller.h:

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
/*
 * Teller.h
 *
 *  Created on: Feb 16, 2014
 *      Author: grantmcgovern
 */

#ifndef TELLER_H_
#define TELLER_H_

#include <iostream>
#include "Customer.h"
#include "QueueNode.h"
#include "Queue.h"

using namespace std;

class Teller
{
private:
	bool isOccupied;
	Customer customer;
public:
	Teller()
	{
		isOccupied = true;
		customer = NULL;
	}
	bool isFree()
	{
		if(isOccupied)
		{
			return true;
		}
		else if(customer.isDone())
		{
			isOccupied = true;
		}
		return isOccupied;
	}
	void addCustomer(Customer C)
	{
		customer = C;
		isOccupied = false;
	}
};



#endif /* TELLER_H_ */ 


DRIVER :


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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*
 * Driver.cpp
 *
 *  Created on: Feb 16, 2014
 *      Author: grantmcgovern
 */
////////////////////////////////////////////////////////////////////
///Includes///
////////////////////////////////////////////////////////////////////
#include <iostream>
#include <vector>
#include "Queue.h"
#include "Customer.h"
#include "QueueNode.h"
#include "Teller.h"

using namespace std;


int main(int argc, char *argv[])
{
	srand(time(NULL)); //seeds the random time generator

	if(argc != 5)
	{
		cout << "You must enter at least 5 command line arguments " << endl;
		exit(1);
	}

	double p = atoi(argv[1]);
	int numTellers = atoi(argv[2]); //number of the tellers (M)
	int maxService = atoi(argv[3]);
	int maxClock = atoi(argv[4]); //simulation time (N)

	Queue<Customer> customerQueue;
	vector<Teller> tellers(numTellers);

	int totalWait = 0;
	int numCustServed = 1;
	cout<<"Customer No. Arrival time Waiting time in queue"<<endl;
	cout<<"------------ ------------ ---------------------"<<endl;

	//////////////////////////////////////////////////////////////////
	for(int i = 1; i < maxClock; i++) //loop begins at 1 and counts up
	{
		if(1 + rand()%10 <= maxService)
		{
			Customer customer(i, maxService);
			customerQueue.enqueue(customer);
			cout << "       " << numCustServed << "        " << i << "      " << totalWait/numCustServed <<endl;
		}
		for(int t = 0; t < numTellers; t++)
		{
			if(tellers[t].isFree() && (!customerQueue.isempty()))
			{
				Customer customer = customerQueue.front();
				tellers[t].addCustomer(customer);
				totalWait = totalWait + (i - customer.getArrivalTime());
				customerQueue.remove(); //dont know about this
				numCustServed++;
			}
		}

		cout << "Total waiting time: " << totalWait << endl;
		cout << "Number of Customers served: " << numCustServed << endl;
		cout << "Average waiting time: " << totalWait/numCustServed<<endl;
		cout << "After service the number of customers left in queue: " <<endl;
		cout << customerQueue.queuecount() << endl;

		cout << "=====================================================" <<endl;

		cout << "\n\n\n Customer No. Arrival time Waiting time in queue" <<endl;
		cout << "------------------------------------------------------" <<endl;

		/*
		while(customerQueue.queuecount() > 0)
		{
			if(1 + rand()%10 <= maxService)
			{
				int currentTime;
				i = currentTime;
				Customer customer(i);
				cout << " " << numCustServed << " " << i << " " << totalWait/numCustServed << endl;
			}
		}
		*/
		while(customerQueue.queuecount() > 0)
		{
			for(int m = 0; m < maxService; m++)
			{
				if(tellers[m].isFree() && (!customerQueue.isempty()))
				{
					Customer customer = customerQueue.front();
					customerQueue.remove();
					cout << "       " << numCustServed << "        " << i << "      " << totalWait/numCustServed <<endl;
				}
			}
		}
		cout << "Total waiting time: " << totalWait << endl;
		cout << "Number of Customers served: " << numCustServed << endl;
		cout << "Average waiting time: " << totalWait/numCustServed<<endl;
		cout << "After service the number of customers left in queue: " <<endl;
		cout << customerQueue.queuecount() << endl;

		return 0;
	}
}



I know this is somewhat long but thank you!
You haven't defined a default constructor for Queue. Because you've defined another constructor (the private one), the compiler won't create a default one for you. You have to define it explicitly.
Topic archived. No new replies allowed.