Basic Queue Please help me debug and finish this code, it should do the functions under the int main(). #include using namespace std; class Qcontainer{ int *Qarr; int front; int rear; int capacity;...


Basic Queue


Please help me debug and finish this code, it should do the functions under the int main().



#include
using namespace std;


class Qcontainer{
int *Qarr;
int front;
int rear;
int capacity;


public:
//constructor
Qcontainer(int Qsize);


//desctructor
~Qcontainer();


//dequeue:int front value, no param
int dequeue(){
if(isEmpty()){
cout <>
return 0;
}


cout < "removing="" "="">< qarr[front]=""><>
int temp = Qarr[front];


int i = front;
while(i<>
Qarr[i] = Qarr[++i]
i++;
}
Qarr[rear] = NULL;
rear = --rear;
return temp;
}


//enqueue:bool add rear value, int data
bool enqueue(int newData){
if(isFull){
cout < "overflow"=""><>
return false;
}


cout < "inserting="" "="">< newdata=""><>
rear = ++rear;
Qarr[rear] = newData;
return true;
}


//front:int return front val, no param
int front(){
return Qarr[front];
}


//isempty:bool, no parameter
bool isEmpty(){
return (rear == -1);
}


//isfull:bool, no parameter
bool isFull(){
return rear==capacity;
}
};


Qcontainer::Qcontainer(int Qsize){
Qarr = new int[Qsize];
front = NULL;
rear = -1;
capacity = Qsize;
}


Qcontainer::~Qcontainer(){
delete [] Qarr;
}


int main(){
//create queue size 10
//enqueue 3 values
//dequeue 1 value
//show the front
//while queue is not empty
//show the front
//dequeue
//destroy queue
}

int main(){<br>Ilcreate queue size 10<br>llenqueue 3 values<br>Ildequeue 1 value<br>Ilshow the front<br>Ilwhile queue is not empty<br>llshow the front<br>Ildequeue<br>Ildestroy queue<br>}<br>

Extracted text: int main(){ Ilcreate queue size 10 llenqueue 3 values Ildequeue 1 value Ilshow the front Ilwhile queue is not empty llshow the front Ildequeue Ildestroy queue }
Jun 10, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here