Test it as you add each new operation. When you\'re done, use the program Qteste
ID: 3922363 • Letter: T
Question
Test it as you add each new operation. When you're done, use the program Qtester.cpp to test your class.
1. << Overload the output operator << so that a statement of the form cout << q; will display q's
contents from front to back.)
2. size() //returns the number of elements in the queue
3. back() // returns the element at the back of a queue
/*
tester.cpp
Program to test class Queue.
Input (keyboard): Commands entered by the user.
Output (screen): List of commands and messages describing
the effects of each command.
----------------------------------------------------------------*/
#include "Queue.h"
#include <iostream>
#include <cctype>
using namespace std;
/*--------------------------------------------------------------
Function to list the available commands.
Output (screen): List of commands.
----------------------------------------------------------------*/
void ShowCommands()
{
cout << "Use the following commands to test the Queue class: "
<< "a --- add an element to the queue "
<< "d --- display contents of queue "
<< "e --- test whether a queue is empty "
<< "f --- retrieve the item at the front of the queue "
<< "h --- help -- print this list of commands "
<< "r --- remove item from front of the queue "
<< "s --- display the size of queue "
<< "b --- retrieve the item at the back of the queue "
<< "q --- quit testing ";
}
int main()
{
QueueElement item; // item to add to the queue
char command; // user command (selected from menu)
Queue q; // The QUEUE
ShowCommands();
do
{
cout << "Command? ";
cin >> command;
if (isupper(command)) command = tolower(command);
switch(command)
{
case 'a':
cout << "Enter item to add to queue: ";
cin >> item;
q.enqueue(item);
cout << "--> " << item << " added ";
break;
case 'd':
cout << "--> Queue contents: " << q << endl;
break;
case 'e':
cout << "--> Queue " << (q.empty() ? "is" : "is not")
<< " empty ";
break;
case 'f':
cout << "--> " << q.front() << " is at the front ";
case 'h':
ShowCommands();
break;
case 'r':
q.dequeue();
cout << "--> Front element removed ";
break;
case 's':
cout << "--> the size of the queue is: " << q.size() << endl;
break;
case 'b':
cout << "--> " << q.back() << " is at the back ";
break;
case 'q':
cout << "--> End of test ";
break;
default:
cout << "*** Illegal command: " << command << endl;
}
}
while (command != 'q');
}
Explanation / Answer
B and C are correct.
Pop -up blockers are used to prevent displaying pop-ups for ads in the browser. It will remove all the ads from publisher websites.
Windows firewall prevents virus to enter the internal network from the external source.