Question: In C++ (Screenshot of output please) Program 1 Write a queue class to implement a queue using an circular array of 12 string elements. Test

In C++ (Screenshot of output please)

Program 1

Write a queue class to implement a queue using an circular array of 12 string elements.

Test the program with the following sequence of code:

queue myQ; ( Use default constructor to initialize front and end to zero. )

cout<< myQ.size() << endl; // number of elements in queue

myQ.dequeue(); // Try to deqeue when the queue is empty. Should catch UNDERFLOW

myQ.enqueue("Fred");

myQ.enqueue("Liv");

myQ.enqueue("Julie");

myQ.enqueue("Rich");

myQ.enqueue("William");

myQ.enqueue("Olo");

myQ.enqueue("Xi");

myQ.enqueue("Chu");

myQ.enqueue("Annie");

myQ.enqueue("Carlos");

myQ.enqueue("Tuyet");

myQ.enqueue("Sue");

myQ.enqueue("Penny"); // Add 1 to many, should catch OVERFLOW

cout<< myQ.front() << endl; // index value

cout<< myQ.end() << endl; // index value

cout<< myQ.size() << endl; // number of elements in queue

cout << myQ.dequeue() << endl;

cout << myQ.dequeue() << endl;

cout << myQ.dequeue() << endl;;

myQ.enqueue("Olive");

myQ.enqueue("Jim");

cout << myQ.dequeue() << endl;

cout << myQ.dequeue() << endl;

cout<< myQ.front() << endl; // index value

cout<< myQ.end() << endl; // index value

cout<< myQ.size() << endl; // number of elements in queue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!