C++How to make this code take a class object instead of int for the vector queue and be able to enqueue and dequeue the object?#include
#include
#include
using namespace std;
void print_queue(queue Q) //This function is used to print queue
{
while (!Q.empty())
{
cout<< Q.front() << \" \";
Q.pop();
}
}
int main()
{
int n = 10;
vector< queue > array_queues(n); //Create vector of queues of size 10, each entry has a queue of type int
array_queues[0].push(3); //Push elements into queue at 0th index of vector
array_queues[0].push(4);
array_queues[0].push(5);
array_queues[3].push(11); //Push elements into queue at 3rd index of vector
array_queues[3].push(1);
array_queues[3].push(8);
array_queues[6].push(31); //Push elements into queue at 6th index of vector
array_queues[6].push(55);
array_queues[6].push(101);
array_queues[6].push(-221);
cout<<\"\n\n\";
for(int i = 0; i < n; i++) //For each element of vector, print its queue
{
cout << \"index = \" << i << \", Queue: \";
print_queue(array_queues[i]);
cout << endl;
}
array_queues[6].pop(); //Dequeuing elements from queue at 6th index of vector
cout<<\"\n\nAfter Dequeuing from 6th index\n\";
for(int i = 0; i < n; i++) //For each element of vector, print its queue
{
cout << \"index = \" << i << \", Queue: \";
print_queue(array_queues[i]);
cout << endl;
}
return 0;
}