Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help debuggine my code so it will pass all the test cases. Please help! / / * * * * * * *
I need help debuggine my code so it will pass all the test cases. Please help!
Write your code below here
template
class QueueForCS : public BaseQueue
public:
TODO: Complete constructor, copy constructor, copy assignment, and destructor, and all other needed methods
QueueForCSconst int capacity;
~QueueForCS;
QueueForCSconst QueueForCS& objToCopy;
const QueueForCS& operatorconst QueueForCS& objToCopy;
void pushbackconst T& data;
void popfront;
T front const;
T back const;
unsigned int size;
private:
TODO: Supply the needed data members
T arr nullptr ;
unsigned int capacity;
unsigned int slots;
unsigned int head;
unsigned int tail;
;
template
QueueForCS::QueueForCSconst int capacity
TODO: Complete this
thisarr new Tcapacity;
thiscapacity capacity;
return;
template
QueueForCS::~QueueForCS
TODO: Complete this
delete thisarr;
template
QueueForCS::QueueForCSconst QueueForCS& objToCopy
thiscapacity objToCopy.capacity;
thisslots objToCopy.slots;
thishead objToCopy.head;
thistail objToCopy.tail;
thisarr new Tthiscapacity;
for unsigned int i ; i thiscapacity; i
thisarri objToCopy.arri;
template
const QueueForCS& QueueForCS::operatorconst QueueForCS& objToCopy
if this &objToCopy
if thisarr nullptr
delete thisarr;
thiscapacity objToCopy.capacity;
thisslots objToCopy.slots;
thishead objToCopy.head;
thistail objToCopy.tail;
thisarr new Tthiscapacity;
for unsigned int i ; i thiscapacity; i
thisarri objToCopy.arri;
return this;
template
void QueueForCS::pushbackconst T& data
if slots
if slots capacity
std::cout "Error: Queue is full." std::endl;
return;
arrtail data;
tail;
if tail capacity
tail ;
slots;
if slots
slots;
template
void QueueForCS::popfront
if slots
std::cout "Error: Queue is empty." std::endl;
return;
head;
if head capacity
head ;
slots;
template
T QueueForCS::front const
if slots
throw std::outofrangeError: Queue is empty.";
return arrhead;
template
T QueueForCS::back const
if slots
throw std::outofrangeError: Queue is empty.";
If tail is at the data is at index capacity
unsigned int tailIndex tail capacity : tail ;
return arrtailIndex;
template
unsigned int QueueForCS::size
if slots
return slots ;
return slots;
Write your code above here
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