Basically, I'm getting an error when I try to append a CD object to my linked list.
What error? This one:
First-chance exception at 0x550257aa (msvcr100d.dll) in Programming 3 Course Project.exe: 0xC0000005: Access violation reading location 0xfeeefee2.
Unhandled exception at 0x550257aa (msvcr100d.dll) in Programming 3 Course Project.exe: 0xC0000005: Access violation reading location 0xfeeefee2.
My code to append:
case 1:
tempCD.defineCD();
cout << "Works" << endl;
CDlist.appendNode(tempCD);
cout << "Still works." << endl;
break;
My linked list's appendNode function code:
//Append List****************************
//***************************************
template <class T>
void TList<T>::appendNode(T newValue)
{
ListNode<T> *newNode;
ListNode<T> *nodePtr;
//Make a new node, store the value.
newNode = new ListNode<T>(newValue);
//If head doesn't exist, set newNode to head.
if (!head)
head = newNode;
//Otherwise, put it at the end of the list.
else
{
nodePtr = head;
while (nodePtr->next)
nodePtr = nodePtr->next;
nodePtr->next = newNode;
}
}
I'm not really certain what's going on, but my output from the switch statement where the appendation is made outputs "Works." but not "Still works." before it crashes, so I'm certain it's happening here.