Queue Numbering system.

I got an error. I dont re-call how to solve this error

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
108
109
110
111
112
113
114
115
116
117
  #include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <time.h>
#include <cstdlib>
#include <iomanip>
#include <Windows.h>
using namespace std;
struct customerList
{
	string customer;
};
queue<customerList> customers;
customerList cust;
void generate();
void total();
void display();
void serve();
void clearScreen();
int main()
{
	int menu = 0;
	while (menu != 5)
	{
		cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" << endl;
		cout << " \tQueue Number System\n" << endl;
		cout << " 1) Generate Queue" << endl;
		cout << " 2) Get total waiting customers" << endl;
		cout << " 3) Display all waiting customers" << endl;
		cout << " 4) Serve Customer" << endl;
		cout << " 5) Exit" << endl;
		cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" << endl << endl;
		cout << "Select Menu: ";
		cin >> menu;
		cout << "\n";
		switch (menu)
		{
		case 1:
			generate();
			break;
		case 2:
			total();
			break;
		case 3:
			display();
			break;
		case 4:
			serve();
			break;
		default:
			cout << "Invalid option. Try again.\n\n";
		}
		clearScreen();
	}
	cout << "Thank you.\n\n";
	system("pause");
}
void generate()
{
	string in;
	char str[26];
	time_t result = time(NULL);
	ctime_s(str, sizeof str, &result);
	customers.push(cust);
	cout << "Queue Number Generated: " << in << " at " << str << endl;
}
void total()
{
	queue <int>::size_type x;
	x = customers.size();
	cout << "Total Customer In Queue: " << x << endl;
	customers.pop();
	x = customers.size();
	cout << "After Serve The Customer, The Total Customer In Queue Is:" << x << endl;
	return;
}
void display()
{     
	int customer;
	 queue <int>names; //from here i get wrong.
	 names=customers.front();
	 while (names != customers.end())
	 {
		 cout << setw(2) << "No." << setw(7) << "Queue" << setw(12) << "Time\n";
		 cout << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
		 cout << customer;
	 }
	 if (customers.empty() == 1)
		 cout << "Queue is empty. Hahaha.\n\n";
}
void serve()
{   
	queue <int> servename;
	servename = customers.begin();
	int search = 0;
	string served;
	cout << "Please key in customer queue number: \n";
	cin >> served;
	while (servename != customers.end())
	{
		cout << "Customer " << served << "is served.[Y/N]: ";
		customers.pop();
		cout << "Queue is updated.\n\n";
		search == 1;
	}
	else 
		servename++;
    if (search == 0)
           cout << "Queue number is not available in system. Try again.";
   }
   Sleep(10000);
   void clearScreen()
   {
	   Sleep(10000);
	   system("cls");
   }
Last edited on
Please copy and paste the exact error message and indicate which line it is referring to.
LB
1>------ Build started: Project: CustomerQueueNumberingSystem, Configuration: Debug Win32 ------
1>  Customer.cpp
1>c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp(82): error C2679: binary '=': no operator found which takes a right-hand operand of type 'customerList' (or there is no acceptable conversion)
1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\queue(101): note: could be 'std::queue<int,std::deque<_Ty,std::allocator<_Ty>>> &std::queue<_Ty,std::deque<_Ty,std::allocator<_Ty>>>::operator =(std::queue<_Ty,std::deque<_Ty,std::allocator<_Ty>>> &&) noexcept(<expr>)'
1>          with
1>          [
1>              _Ty=int
1>          ]
1>  c:\program files (x86)\microsoft visual studio 14.0\vc\include\queue(43): note: or       'std::queue<int,std::deque<_Ty,std::allocator<_Ty>>> &std::queue<_Ty,std::deque<_Ty,std::allocator<_Ty>>>::operator =(const std::queue<_Ty,std::deque<_Ty,std::allocator<_Ty>>> &)'
1>          with
1>          [
1>              _Ty=int
1>          ]
1>  c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp(82): note: while trying to match the argument list '(std::queue<int,std::deque<_Ty,std::allocator<_Ty>>>, customerList)'
1>          with
1>          [
1>              _Ty=int
1>          ]
1>c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp(83): error C2039: 'end': is not a member of 'std::queue<customerList,std::deque<_Ty,std::allocator<_Ty>>>'
1>          with
1>          [
1>              _Ty=customerList
1>          ]
1>c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp(95): error C2039: 'begin': is not a member of 'std::queue<customerList,std::deque<_Ty,std::allocator<_Ty>>>'
1>          with
1>          [
1>              _Ty=customerList
1>          ]
1>c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp(100): error C2039: 'end': is not a member of 'std::queue<customerList,std::deque<_Ty,std::allocator<_Ty>>>'
1>          with
1>          [
1>              _Ty=customerList
1>          ]
1>c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp(105): warning C4553: '==': operator has no effect; did you intend '='?
1>c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp(107): error C2181: illegal else without matching if
1>c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp(108): error C2676: binary '++': 'std::queue<int,std::deque<_Ty,std::allocator<_Ty>>>' does not define this operator or a conversion to a type acceptable to the predefined operator
1>          with
1>          [
1>              _Ty=int
1>          ]
1>c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp(112): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp(112): error C2365: 'Sleep': redefinition; previous definition was 'function'
1>  c:\program files (x86)\windows kits\8.1\include\um\synchapi.h(908): note: see declaration of 'Sleep'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
It would help if you described the error you're getting.

Line 14: customers is a std:queue of type <customerList>.
Line 81: names is a std::queue of type <int>
Line 82: customers.front() returns a value_type (which is a customerList). You then try to assign that to a queue<int> type. Those are different types. You can't assign one to the other.
AbstractionAnon

This is the list of errors i got.

1.
Error	C2679	binary '=': no operator found which takes a right-hand operand of type 'customerList' (or there is no acceptable conversion)	CustomerQueueNumberingSystem	c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp	82
2.
Severity	Code	Description	Project	File	Line
Error (active)		no operator "=" matches these operands	CustomerQueueNumberingSystem	c:\Users\user\Documents\Visual Studio 2015\Projects\CustomerQueueNumberingSystem\CustomerQueueNumberingSystem\Customer.cpp	82
3. 
Severity	Code	Description	Project	File	Line
Error	C2039	'end': is not a member of 'std::queue<customerList,std::deque<_Ty,std::allocator<_Ty>>>'	CustomerQueueNumberingSystem	c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp	83
4.
Severity	Code	Description	Project	File	Line
Error (active)		class "std::queue<customerList, std::deque<customerList, std::allocator<customerList>>>" has no member "end"	CustomerQueueNumberingSystem	c:\Users\user\Documents\Visual Studio 2015\Projects\CustomerQueueNumberingSystem\CustomerQueueNumberingSystem\Customer.cpp	83
5.
Severity	Code	Description	Project	File	Line
Error	C2039	'begin': is not a member of 'std::queue<customerList,std::deque<_Ty,std::allocator<_Ty>>>'	CustomerQueueNumberingSystem	c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp	95
6.
Severity	Code	Description	Project	File	Line
Error (active)		class "std::queue<customerList, std::deque<customerList, std::allocator<customerList>>>" has no member "begin"	CustomerQueueNumberingSystem	c:\Users\user\Documents\Visual Studio 2015\Projects\CustomerQueueNumberingSystem\CustomerQueueNumberingSystem\Customer.cpp	95
7.
Severity	Code	Description	Project	File	Line
Error	C2039	'end': is not a member of 'std::queue<customerList,std::deque<_Ty,std::allocator<_Ty>>>'	CustomerQueueNumberingSystem	c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp	100
8.
Severity	Code	Description	Project	File	Line
Error (active)		class "std::queue<customerList, std::deque<customerList, std::allocator<customerList>>>" has no member "end"	CustomerQueueNumberingSystem	c:\Users\user\Documents\Visual Studio 2015\Projects\CustomerQueueNumberingSystem\CustomerQueueNumberingSystem\Customer.cpp	100
9.
Severity	Code	Description	Project	File	Line
Warning	C4553	'==': operator has no effect; did you intend '='?	CustomerQueueNumberingSystem	c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp	105

10.
Severity	Code	Description	Project	File	Line
Error	C2181	illegal else without matching if	CustomerQueueNumberingSystem	c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp	107
12.
Severity	Code	Description	Project	File	Line
Error (active)		expected a statement	CustomerQueueNumberingSystem	c:\Users\user\Documents\Visual Studio 2015\Projects\CustomerQueueNumberingSystem\CustomerQueueNumberingSystem\Customer.cpp	107
13.
Severity	Code	Description	Project	File	Line
Error	C2676	binary '++': 'std::queue<int,std::deque<_Ty,std::allocator<_Ty>>>' does not define this operator or a conversion to a type acceptable to the predefined operator	CustomerQueueNumberingSystem	c:\users\user\documents\visual studio 2015\projects\customerqueuenumberingsystem\customerqueuenumberingsystem\customer.cpp	108
The error message is quite clear. What are you trying to accomplish on line 82?
It seems that he wants to iterate over the queue...
LB

I wish to push front the customer generated numbers into the display.
Then why did you use operator= instead of push()?
LB


corrected. Thank you my friend.
Last edited on
Topic archived. No new replies allowed.