Question: Modify the Queue.h file to be a templated Queue class. The queue class will add to the back of the queue and remove items from
Modify the Queue.h file to be a templated Queue class.
The queue class will add to the back of the queue and remove items from the front.
Don't forget to check your class with numbers and strings to make sure it works.
Queue.h
#pragma once
#include
using namespace std;
struct Node{
string data;
Node*next;
};
class Queue
{
public:
//Constructs an empty queue
Queue();
//Destructor to free up memory
~Queue();
//Returns true if the stack is empty
bool isEmpty();
//Adds an item to the end of the queue
void add(string data);
// Removes the item at the front of the queue
void remove();
// Returns the value in the front of the queue (without removing)
string peek();
//Overloads the extraction operator to display the queue
friend ostream &operator << (ostream &out, const Queue &s);
private:
Node *front;
Node *back;
};
Step by Step Solution
3.49 Rating (149 Votes )
There are 3 Steps involved in it
Heres the modified Queue class as a templated class that works with both numbers and strings pragma ... View full answer
Get step-by-step solutions from verified subject matter experts
