Question
the commented are the directions source .cpp #include q.h int main(void) { Queue q(4); q.Display(); q.Enqueue(20); q.Enqueue(30); q.Enqueue(40); q.Enqueue(50); q.Display(); q.Enqueue(60); q.Display(); q.Dequeue(); q.Dequeue(); q.Display();
the commented are the directions
source .cpp
#include \"q.h\"
int main(void) { Queue q(4); q.Display(); q.Enqueue(20); q.Enqueue(30); q.Enqueue(40); q.Enqueue(50); q.Display(); q.Enqueue(60); q.Display(); q.Dequeue(); q.Dequeue(); q.Display(); system(\"pause\"); return 0; }
q.cpp
#include \"q.h\"
template Queue::Queue(int c) { //TODO: initialize private parameters, c is the size of the dynamic array
}
template Queue::~Queue() { //TODO: delete the array }
template void Queue::Enqueue(T data) { //TODO: to insert an element at the rear of the queue return; }
template void Queue::Dequeue() { //TODO: to delete an element from the front of the queue return; }
template void Queue::Display() { int i; if (front == rear) { cout return; } for (i = front; i { cout } cout return; }
template class Queue;
q.h
#pragma once #include #include #include
using namespace std;
template class Queue { public: Queue(int c); ~Queue(); void Enqueue(T data); void Dequeue(); void Display(); private: int front, rear, capacity; T* queue; };
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