so i'm really struggling with this program, i'm new to c++, i have most parts done, but can't figure out my queuetype code ... i know what needs to be done, just can't figure out the code
Code:
#include "QueueType.h"
QueueType::QueueType(void)
{
front = NULLNODE;
back = NULLNODE;
}
QueueType::~QueueType(void)
{
MakeEmpty();
}
bool QueueType::IsEmpty() const
{
// How can we tell if the queue is empty?
return false;
}
bool QueueType::IsFull() const
{
try
{
NodeType *tmp = new NodeType();
delete tmp;
return false;
}
catch (std::bad_alloc ex)
{
return true;
}
}
void QueueType::MakeEmpty()
{
while (! IsEmpty())
Dequeue();
}
void QueueType::Enqueue(ItemType item)
{
NodeType *newNode = new NodeType();
// Store data in the node and initialize next
// Case 1: The queue is currently empty
if (IsEmpty())
{
// Point front and back to newNode
}
// Case 2: The queue is not currently empty
else
{
// Point the next of back to the new node
// Move the back pointer to point to the new node
}
}
ItemType QueueType::Dequeue()
{
ItemType itemToReturn;
// Store the item to return
// Delete the first node in the queue
// If we just deleted the last node in the queue, also set back to NULLNODE
return itemToReturn;
}
anyone have any suggestions