Created
March 7, 2012 23:25
-
-
Save fivetanley/1997174 to your computer and use it in GitHub Desktop.
Fuuuuuuuuuuck.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Node* LinkedList::removeAtHead() | |
{ | |
if (!head) | |
{ | |
return 0; | |
} | |
Node* firstNode = head; | |
//Advance to the second position in the linked list because | |
//the first one will be popped off and (hopefully) deleted by the process | |
//requesting it.. | |
Node* secondNode = (*firstNode).next; | |
//Remove the reference to the old first Node to prevent memory leaking. | |
//Set the new first Node of the list to the | |
head = secondNode; | |
firstNode->next = 0; | |
return firstNode; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment