//______________________________________________________________________________________void S_LIST::sl_clear() { struct ListItem *cur,*next; if ( MyList == 0) return; for(cur = MyList; cur != 0; cur = next ) { next = cur->next; delete (cur); } MyList = 0; return;}
Should this code delete a singley linked list?
here's some basic code that i use. You can try to adapt for your's...
I once wrote a recursively deleting list. Just make things simpler, use iteration. You wouldn't want your list deletion to cause a stack overflow, would you? ;)
Quote:Original post by Tonic151Not bad, except this line:
here's some basic code that i use. You can try to adapt for your's...
*** Source Snippet Removed ***
if ( MyList == 0) return;
is completely redundant!
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement