Hi. I'm getting a segmentation fault when I get to the loop in main trying to print out the characters. I think my insertInOrder and insert functions are wrong, but I just can't figure out anything. I'm new to double linked lists and new to templates. Oh, and I ignored all the other functions in the LinkedList class because they were working last time I checked. So I narrowed it down to the insert and insertInOrder. Any help would be appreciated.
Thanks
--
James
bool (*charcmp)(T, T)? (Possibly const references on the Ts)
Anyway, check your insertInOrder(). What happens if you have one element, say 'a', and you are trying to add 'z'? You'd check it against the front, it would be true, you'd go to the next element (NULL I assume), then the next check would crash.
Also, using the member variable curr to store state seems kind of hard to understand. Just make a temporary variable and pass it around if you need it.
I'm sorry if I'm making some stupid mistake. I just can't figure this thing out.
EDIT: Ok, so now the insertinOrder works, I guess. It doesn't segmentation fault at least. But the stuff is out of order. But then it segmentation faults later on in the program when I try to clear the list. I'm working on my clear() function right now
Am I getting closer? I've been screwing with this code for 3 days. I've asked one of my classmates and both of us put together can't figure out the insertInOrder function. We have the rest of the program figured out, but it's this one function.