That makes sense. Although, if I had a line after a call to this function that says delete head;
I get a malloc error. Why do I not get an error at line 12??
I'm still not sure why I would get a malloc error outside the function but not inside. However, since head was a part of main I needed to change my deleteList function's parameters to pass the Node* by reference so that head ends up as a NULL pointer upon completion of the function. void deleteList(Node*& head)
Once all of these are member functions of a class the pass by reference will not be needed.
In the calling code, head still points to the same place. Only a copy of the pointer is sent to deleteList. The fact that it is referred to by a variable of the same name is coincidental.