|
|
(lldb) run Process 62607 launched: '/home/Stored Documents/Programs/C++/Experiment programs/linked_list' (x86_64) Process 62607 stopped * thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1 frame #0: 0x0000000100000f93 linked_list`main(argc=1, argv=0x00007ffeefbffab0) at linked_list.cc:27 24 25 list1.add (2.5); 26 -> 27 list1.add (103); 28 29 list1.add (85.021); 30 Target 0: (linked_list) stopped. (lldb) print list1.head -> value (double) $0 = 2.5 (lldb) print list1.head -> next (List::Node *) $1 = 0x0000000000000000 |
............................................________ ....................................,.-‘”...................``~., .............................,.-”...................................“-., .........................,/...............................................”:, .....................,?......................................................\, .................../...........................................................,} ................./......................................................,:`^`..} .............../...................................................,:”........./ ..............?.....__.........................................:`.........../ ............./__.(.....“~-,_..............................,:`........../ .........../(_....”~,_........“~,_....................,:`........_/ ..........{.._$;_......”=,_.......“-,_.......,.-~-,},.~”;/....} ...........((.....*~_.......”=-._......“;,,./`..../”............../ ...,,,___.\`~,......“~.,....................`.....}............../ ............(....`=-,,.......`........................(......;_,,-” ............/.`~,......`-...............................\....../\ .............\`~.*-,.....................................|,./.....\,__ ,,_..........}.>-._\...................................|..............`=~-, .....`=~-,_\_......`\,.................................\ ...................`=~-,,.\,...............................\ ................................`:,,...........................`\..............__ .....................................`=-,...................,%`>--==`` ........................................_\..........._,-%.......`\ ...................................,<`.._|_,-&``................`\ |
|
|
I hate it when people do that...it looks so confusing. It's easier to visually debug if people add curly brackets. |
|
|
|
|
|
|
|
|
|
|
I can't understand why people put the brace right after the statement |
|
|
103 is a member! 13.6 is not a member. Displaying List1: 2.5 103 85.24 12.001 Displaying List2: 2.5 103 85.24 12.001 linked_list(85597,0x7fff9d3f9380) malloc: *** error for object 0x7fdb14400030: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug Abort trap: 6 |
|
|
Displaying values l1: 2.5 103 85.021 Displaying values l2: 2.5 103 85.021 |
+---+ +---+ +---+ original | +---> +---> +---> null +---+ +-^-+ +---+ | +---+ | copy | +-----+ +---+ |
|
|
What's that code, exactly? It looks for all the world like the C++ standard header files |
Of course!!! I should have used the add() function inside the copy constructor!!! |
if (cond) statement;
|
|
|
|
|
|
anotherStatement
isn't actually inside the if
condition.
|
|
|
|
|
|
|
|
|
|
dhayden wrote: |
---|
So why let braces push you around? |
|
|
|
|
|
|
dhayden wrote: |
---|
That code is quite literally double spaced. |
Ganado, Wow, that's cool! I remember circular linked lists. Need to brush up on them so I can try writing my own again sometime... |
Of course!!! I should have used the add() function inside the copy constructor!!! No, you definitely should NOT. Using your add() function makes the copy constructor run in O(n2) time. |
|
|
Node **
to the head, or the last Node's next pointer. It other words, it points to where the next node will be linked in.
|
|
for
loop looks complicated but it really just walks src and dst down two lists at the same time. src points to the current node in the source list. dst points to the pointer where it will be linked in.
dhayden wrote: |
---|
Using your add() function makes the copy constructor run in O(n2) time. |