Need help with my program

Hi! For the Enqueue function part, im not so sure on how to insert a new customer into the queue.
Here is the part of the question for more clarification.


-queue’s member length represents the number of customers in the queue, and these customers take the place (index) of 0 to length-1 of queue’s member CustomerList.*/

-If queue is not full (think how you know whether the queue is full or not), insert cus to the tail of the queue (that is, the place (or index) length of queue’s member CustomerList, CustomerList[length]) and update the number of customers in the queue; otherwise, print out ”the queue is full”.

I posted what i have so far, its wrong and keeps giving me an error "no operator == matches these operand.

Any help and assistance will be appreciated!

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
  #include<iostream>

using namespace std;

struct Customer
{
	string character;
	int ArrivalTime;
	int ServiceTime;
	int FinishTime;

};
bool IsEmpty(FCFSQueue);
int GetLength(FCFSQueue);
void Enqueue(FCFSQueue&, Customer);

struct FCFSQueue
{
	Customer CustomerList[100] = {};
	int length;

};

bool IsEmpty(FCFSQueue queue)
{
	
		//if queue’s member length is 0, return true; otherwise, return false
	if (queue.length = 0)
		return true;
	else
		return false;


}
int GetLength(FCFSQueue queue)
{
	//return queue’s member length
	return queue.length;
}
void Enqueue(FCFSQueue &queue, Customer cus)
{
	if (queue.length == queue.CustomerList[100])
		{
			cout << "The queue is full" << endl;

		}

		else if (queue.length != 100)
		{
			queue.CustomerList[cus];
			
			

		}
	
	
	
}
Last edited on
Line 28: queue.length = 0 means you assign 0. Change it to queue.length == 0

Line 42: You cannot compare the length with a Customer. You need the number (like on line 48).
Better like so:
1
2
3
4
5
6
7
8
9
10
11
12
		if (queue.length < 100)
		{
			queue.CustomerList[queue.length] = cus;
			++queue.length;
		}
		else
		{
			cout << "The queue is full" << endl;
			
			

		}
thank you!
Topic archived. No new replies allowed.