Start New Discussion within our Software Development Community

I am given the class definition of stack and queue classes where I have to write a templated function called reverseQueue(?) that takes a pointer to queue as a parameter and uses stack object to reverse the given queue. The function call to reverseQueue should reverse the data of the passed as a parameter.

template <class T>
struct NODE {
NODE<T> *pNext;
T Data;
};
template <class T>
class stack{
private:
NODE<T> * top;
public:
stack();
~stack();
void push (T data); //pushes a new node with data
type T in a stack
bool pop (T &data); //pops out the top most node
from the stack
void printStack(); //prints all elements of a stack
};

template <class Type>
class queue {
private:
NODE<T> * front;
NODE<T> * tail;
public:
queue ();
~queue();
bool dequeue ( Type & data); //removes first node
from a queue
bool enqueue (Type val); //appends a new node in
a queue
};