This is the method. Define a queue overflow exception and modify enqueue so that it throws this exception when the queue runs out of space.
this is my code:
void IntQueue::enqueue(int num)
{
if (isFull())
cout << "The queue is full.\n";
else
{
// Calculate the new rear position
rear = (rear + 1) % queueSize;
// Insert new item
queueArray[rear] = num;
// Update item count
numItems++;
}
}
how can i insert an exception message here?