on the same line of our previous post, here is how to write Queue in c++:
[cpp]
<pre>
#include <iostream.h>
struct node
{
int data;
node *link;
};
class queue
{
private:
node *front, *rear;
public:
queue()
{
front = rear = NULL;
}
void addq(int item)
{
node *temp;
temp = new node;
if(temp == NULL)
cout << endl << "Queue is full";
temp->data = item;
temp->link = NULL;
if(front == NULL)
{
rear = front = temp;
return;
}
rear->link = temp;
rear = rear->link;
}
int delq()
{
if(front == NULL)
{
cout << endl << "Queue is empty";
return;
}
node *temp;
int item;
item = front->data;
temp = front;
front = front->link;
delete temp;
return item;
}
~queue()
{
if(front == NULL)
return;
node *temp;
while(front != NULL)
{
temp = front;
front = front->link;
delete temp;
}
}
};</pre>
[/cpp]
What's up, its good article regarding media print, we all know
ReplyDeletemedia iis a fantastic source off facts.
What's up, yes this post is truly fastidious and I havce learned lot
ReplyDeleteof things from iit on the topic of blogging. thanks.
You're so cool! I do not beliesve I've truly read through anything like that
ReplyDeletebefore. So wonderful to discover someone with unique thoughts on this issue.
Seriously.. thanks for starting this up.
This web site is something that is required on the web, someone with a bit
of originality!