Question
I'm not sure I am on the right track with this assignment. Assignent: Write a template queue class as defined below: private data member: a
I'm not sure I am on the right track with this assignment.
Assignent:
Write a template queue class as defined below:
private data member: a STL list
public member functions:
-empty
-size
-enqueue
-deque
-front
-back
Then write a driver to test the above queue class.
My code:
Header.h
#include using namespace std; template
bool empty() { return QList.empty(); }
int size() { QList.size(); }
bool enqueue(const T & x) { list.push_back(x); rear = rear + 1; count = count + 1; return true; }
bool dequeue(const T & x) { if (!empty()) { QList.pop_front(); count--; Front = Front + 1; return true; } return false; } typedef int QueueElement front() const { return QList.front(); }
typedef int QueueElement back() const { return QList.back(); } };
Source.cpp
#include "Header.h" #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started