Now I'am using Microsoft Visual Studio

Now I'am using Microsoft Visual Studio to compile this program in C++ but I have this error:
1>c:\users\user\documents\visual studio 2008\projects\c++\c++\c++.cpp(97) : error C3861: 'display': identifier not found

And this is the program:

# include<iostream>
using namespace std;
# define SIZE 5


class queue
{
private:
int a[SIZE];
int front;
int rear;
public:
queue();
~queue();
void insert(int i);
int remove();
int isempty();
int isfull();
int display(int n);
};

queue::queue()
{
front=0;
rear=0;
}
queue::~queue()
{

}
void queue::insert(int i)
{
if(isfull())
{
cout<<"\n******Queue is FULL !!!No insertion allowed further.******";
return;
}
a[rear] = i;
rear++;
}
int queue::remove()
{


if(isempty())
{
cout<<"\n******Queue Empty !!!Value returned will be garbage.******\n";

return (-9999);
}
int i = SIZE ;
while( i--)
{
a[i] = 0;
};

return(a[0]);

}

int queue::isempty()
{
if(front == rear)
return 1;
else
return 0;
}

int queue::isfull()
{
if(rear == SIZE)
return 1;
else
return 0;
}
int queue::display( int n )
{
int i = a[n];
return i;
}

void main()
{

queue q;
int item;

while (!q.isfull())
{
cin>>item;
q.insert(item);
}

while(!q.isempty())
{
int n = SIZE ;
cout << display( n) ;
n--;
}

cout<<"\n "<<q.remove();
cout<<"\n"<<q.remove();

}
Next time, please use code-tags. Makes it much easier for us to read and point out errors.

Anyway, display() is a part of the queue class. Thus, you need to use it "on" a queue object.

Change:
cout << display( n);
to
cout << q.display(n);
Last edited on
OK..thank you but when I compile it I have so many 00000 with no end for this procces..

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
# include<iostream>
using namespace std;
# define SIZE 3


class queue
{
	private:
			int a[SIZE];
			int front;
			int rear;
	public:	
			queue();
			~queue();
			void insert(int i);
			int remove();
			int isempty();
			int isfull();
			int display(int n);
};

queue::queue()
{
	front=0;
	rear=0;
}
queue::~queue()
{
	
}
void queue::insert(int i)
{
	if(isfull())
	{
		cout<<"\n******Queue is FULL !!!No insertion allowed further.******";
		return;
	}
		a[rear] = i;
		rear++;
}
int queue::remove()
{


	if(isempty())
	{
			cout<<"\n******Queue Empty !!!Value returned will be garbage.******\n";

			return (-9999);
	}
	int i = SIZE ; 
	while( i--)
	{
		a[i] = 0;
	};

	return(a[0]);

}

int queue::isempty()
{
	if(front == rear)
		return 1;
	else
	return 0;
}

int queue::isfull()
{
	if(rear == SIZE)
		return 1;
	else
		return 0;
}
int queue::display( int n )
{
	int i = a[n];
	return i; 
}

void main()
{
	
	queue q;
	int item;

	while (!q.isfull())
	{
		cin>>item;
		q.insert(item);
	}

	while(!q.isempty())
	{
		int n = SIZE ;
		
		cout<<q.display(n);
		n--;
	}

	cout<<"\n "<<q.remove();
	cout<<"\n"<<q.remove();
	
}
Last edited on
Your "remove" function doesn't make sense to me. In its current form, calling it twice without any other operations in between has no point as a single call sets every item to 0.
What exactly do you want it to do?
I want the user continue to input and it is full, Display a message, "It's Full!".
and Allow the user to choose an option, to delete an item or not, if the user delete an item, display the item deleted. If the user choose not to delete, display all the items.
That What I want..
You never decrement "rear" variable, even on queue::remove, which you should do.
Thanks I understand now..
But where i decrement in the program I didn`t understand ..
Topic archived. No new replies allowed.