#include <iostream>
const int MAX_SIZE = 5;
class CircularQueue {
private:
int front;
int rear;
int queue[MAX_SIZE];
public:
CircularQueue() {
front = -1;
rear = -1;
}
bool isEmpty() {
return (front == -1 && rear == -1);
}
bool isFull() {
return ((rear + 1) % MAX_SIZE == front);
}
void enqueue(int item) {
if (isFull()) {
std::cout << "Queue is full. Cannot enqueue element.\n";
return;
}
if (isEmpty()) {
front = rear = 0;
} else {
rear = (rear + 1) % MAX_SIZE;
}
queue[rear] = item;
std::cout << "Enqueued " << item << " into the queue.\n";
}
};
int main() {
CircularQueue cq;
cq.enqueue(8);
return 0;
}