Hey there I am to copy going to copy my function and please tell me how do imple
ID: 3652419 • Letter: H
Question
Hey there I am to copy going to copy my function and please tell me how do implement the circular queue#include<iostream>
#include<string>
#include "queues.h"
using namespace std;
queue::queue()
{
front=0;
rear=0;
}
queue::~queue(){}
void queue::enqueue(string name)
{
if(isfull())
{
cout<<"Queue is full. No insertion allowed further."<<endl;
return;
}
names[rear] = name;
rear++;
}
void queue::enqueue(string name, bool premium)
{
if(isfull())
{
cout<<"Queue is full. No insertion allowed further."<<endl;
return;
}
if(premium == true)
{
string oldName = "";
for(int i = front; i < rear; i++)
{
oldName = names[i];
names[i] = name;
name = oldName;
}
}
names[rear] = name;
rear++;
}
string queue:: dequeue()
{
if(isempty())
{
cout<<"Queue is empty. Value returned from the queue will be garbage."<<endl;
exit(0);
}
return(names[front++]);
}
int queue::isempty()
{
if(front == rear)
return 1;
else
return 0;
}
int queue::isfull()
{
if(rear == SIZE)
return 1;
else
return 0;
}
void queue::displayQueue()
{
cout<<"QUEUE:"<<endl;
for(int i = front; i < rear; i++)
{
cout<< names[i] << endl;
}
}