🎯 Objective
Design and implement a queue in C++ to store integer values. This project will help you understand the concept of queues, their structure, and their usage in C++.
\uD83D\uDDD2 Requirements
Create a class called
Queue
with the following attributes:int* arr
int front
int rear
int capacity
Add the following methods to the
Queue
class:A constructor that takes an integer capacity as a parameter and initializes the
arr
,front
,rear
, andcapacity
attributes.A destructor that deallocates the memory of the
arr
attribute.A method called
enqueue()
that takes an integer value as a parameter and adds it to the rear of the queue. If the queue is full, display an appropriate error message.A method called
dequeue()
that removes the element at the front of the queue and returns its value. If the queue is empty, display an appropriate error message.A method called
isEmpty()
that returns a boolean value indicating whether the queue is empty or not.A method called
isFull()
that returns a boolean value indicating whether the queue is full or not.A method called
size()
that returns the number of elements in the queue.A method called
peek()
that returns the value of the element at the front of the queue without removing it. If the queue is empty, display an appropriate error message.
In the
main()
function, demonstrate the usage of theQueue
class. Create aQueue
object, perform enqueue and dequeue operations, and call theisEmpty()
,isFull()
,size()
, andpeek()
methods to display the queue's state.
🚚 Deliverable
Upload the following:
Full source code (.cpp files or .txt files)
Screenshot of the Console with the code executing