How do you delete the front cell of an array in an array based circular queue?
Here's the Queue cpp functions
#include <iostream>
#include <string>
#include "Contributor.h"
#include "myQueue.h"
using namespace std;
myQueue::myQueue()
{
front=0;
rear =0;
Index=0;
size= 0;
ArrayQ[10];
}
myQueue::myQueue(const myQueue &CCmyQueue)
{
for(int i=0;i < CCmyQueue.Index;i++)
{
ArrayQ[i]=CCmyQueue.ArrayQ[i];
front= CCmyQueue.front;
rear =CCmyQueue.rear;
Index=CCmyQueue.Index;
size =CCmyQueue.size;
}
}
myQueue &myQueue:: operator =(const myQueue & RHS)
{
if(this!= &RHS)
{
for (int i=0; i<RHS.Index;i++)
{
ArrayQ[i]= RHS.ArrayQ[i];
Index = RHS.Index;
rear= RHS.rear;
front= RHS.front;
size= RHS.size;
}
}
return *this;
}
myQueue::~myQueue()
{
cout<< "default D-Tor"<<endl;
}
bool myQueue::enQueue(Contributor InData)
{
if(IsFull())
{
cout<< " Queue is full"<<endl;
return false;
}
else
{
ArrayQ[rear]=InData;
step(rear);
Index++;
}
cout<<"Index ="<<Index<<endl;
return true;
}
bool myQueue::deQueue()
{
if(IsEmpty())
{
cout<<"the IsEmpty()"<< endl;
}
else
{
//code for deleting the front data?
step(front);
--Index;
}
return true;
}
bool myQueue::IsFull()
{
if(Index==MAXSIZE)
{
return true;
}
return false;
}
bool myQueue::IsEmpty()
{
if(Index==0)
{
return true;
}
return false;
}
void myQueue::step(int &num)
{
if(num==(size-1))
{
num=0;
}
else
{
num++;
}
}
void myQueue::ShowFront()
{
cout<<"this is the Front Object"<<endl;
cout<<ArrayQ[front]<<endl;
}
void myQueue::ShowRear()
{
cout<<"this is the Rear Object "<<endl;
cout<<ArrayQ[rear-1]<<endl;
}
void myQueue::PrintQ()
{
for (int i=0;i<Index;++i)
{
cout<<ArrayQ[i];
}
}