I'm having Buss Error issues. I feel that it has to do with either my deconstuctor or my insert/delete functions.
I know I'm not supposed to put up whole source code, but I will put it up if needed.
Assume that ItemType is an integer and Next is a pointer.
void ItemList::Insert(ItemType item)
{
NodePtr currPtr;
NodePtr prevPtr;
NodePtr location;
location = new NodeType;
location->item = item;
prevPtr = NULL;
currPtr = listPtr -> next;
while (currPtr != NULL && item != currPtr->item )
{
prevPtr = currPtr; // Advance both pointers
currPtr = currPtr->next;
}
location->next = currPtr;// Insert new node here
if (prevPtr == NULL)
listPtr -> next = location;
else
prevPtr->next = location;
// FILL IN Code.
}
//***********************************************************
void ItemList::Delete(ItemType item)
{
NodePtr delPtr;
NodePtr currPtr; // Is item in first node?
if (item == listPtr->item)
{ // If so, delete first node
delPtr = listPtr;
listPtr = listPtr->next;
}
else // Search for item in rest of list
{
currPtr = listPtr;
while (currPtr->next->item != item)
currPtr = currPtr->next;
delPtr = currPtr->next;
currPtr->next = currPtr->next->next;
}
delete delPtr;
}
ItemList::~ItemList()
// Post: All the components are deleted.
{
while (listPtr -> next != NULL)
delete listPtr;
if(listPtr -> next == NULL)
delete listPtr;
}