@ne555, ah that was easier than I thought it would be. I don't really understand the backtrace part though.
Also, I don't want to use an IDE. Since the course I'm doing at the moment requires that all programs compile and run in cygwin, I'd rather just use it and nothing else. Even if I don't quite understand it all.
Anyway here's what I got when I debugged:
"Starting program: /cygdrive/c/uni/seng1120/lab5/list_test
[New Thread 14156.0x2788]
[New Thread 14156.0x21ec]
0
Please enter a number:
1
1
Please enter a number:
2
2
Please enter a number:
3
3
Please enter a number:
4
4
Please enter a number:
5
5
Program received signal SIGSEGV, Segmentation fault.
0x000000010040110b in banfield_lab5::node::~node() ()
(gdb) backtrace
#0 0x000000010040110b in banfield_lab5::node::~node() ()
#1 0x0000000100401131 in banfield_lab5::node::~node() ()
#2 0x000000010040114e in banfield_lab5::node::~node() ()
#3 0x0000000100401131 in banfield_lab5::node::~node() ()
#4 0x000000010040114e in banfield_lab5::node::~node() ()
#5 0x0000000100401131 in banfield_lab5::node::~node() ()
#6 0x000000010040114e in banfield_lab5::node::~node() ()
#7 0x0000000100401131 in banfield_lab5::node::~node() ()
#8 0x000000010040114e in banfield_lab5::node::~node() ()
#9 0x0000000100401131 in banfield_lab5::node::~node() ()
#10 0x000000010040114e in banfield_lab5::node::~node() ()
#11 0x0000000100401131 in banfield_lab5::node::~node() ()
#12 0x000000010040114e in banfield_lab5::node::~node() ()
#13 0x0000000100401131 in banfield_lab5::node::~node() ()
#14 0x000000010040114e in banfield_lab5::node::~node() ()
#15 0x0000000100401131 in banfield_lab5::node::~node() ()
#16 0x000000010040114e in banfield_lab5::node::~node() ()
#17 0x0000000100401131 in banfield_lab5::node::~node() ()
#18 0x000000010040114e in banfield_lab5::node::~node() ()
#19 0x0000000100401131 in banfield_lab5::node::~node() ()
#20 0x000000010040114e in banfield_lab5::node::~node() ()
#21 0x0000000100401131 in banfield_lab5::node::~node() ()
#22 0x000000010040114e in banfield_lab5::node::~node() ()
#23 0x0000000100401131 in banfield_lab5::node::~node() ()
#24 0x000000010040114e in banfield_lab5::node::~node() ()
#25 0x0000000100401131 in banfield_lab5::node::~node() ()
#26 0x000000010040114e in banfield_lab5::node::~node() ()
#27 0x0000000100401131 in banfield_lab5::node::~node() ()
#28 0x000000010040114e in banfield_lab5::node::~node() ()
#29 0x0000000100401131 in banfield_lab5::node::~node() ()
#30 0x000000010040114e in banfield_lab5::node::~node() ()
#31 0x0000000100401131 in banfield_lab5::node::~node() ()
#32 0x000000010040114e in banfield_lab5::node::~node() ()
#33 0x0000000100401131 in banfield_lab5::node::~node() ()
#34 0x000000010040114e in banfield_lab5::node::~node() ()
#35 0x0000000100401131 in banfield_lab5::node::~node() ()
#36 0x000000010040114e in banfield_lab5::node::~node() ()
#37 0x0000000100401131 in banfield_lab5::node::~node() ()
#38 0x000000010040114e in banfield_lab5::node::~node() ()
#39 0x0000000100401131 in banfield_lab5::node::~node() ()
#40 0x000000010040114e in banfield_lab5::node::~node() ()
#41 0x0000000100401131 in banfield_lab5::node::~node() ()
#42 0x000000010040114e in banfield_lab5::node::~node() ()
#43 0x0000000100401131 in banfield_lab5::node::~node() ()
#44 0x000000010040114e in banfield_lab5::node::~node() ()
#45 0x0000000100401131 in banfield_lab5::node::~node() ()
#46 0x000000010040114e in banfield_lab5::node::~node() ()
#47 0x0000000100401131 in banfield_lab5::node::~node() ()
#48 0x000000010040114e in banfield_lab5::node::~node() ()
#49 0x0000000100401131 in banfield_lab5::node::~node() ()
#50 0x000000010040114e in banfield_lab5::node::~node() ()
#51 0x0000000100401131 in banfield_lab5::node::~node() ()
#52 0x000000010040114e in banfield_lab5::node::~node() ()
#53 0x0000000100401131 in banfield_lab5::node::~node() ()
#54 0x000000010040114e in banfield_lab5::node::~node() ()
#55 0x0000000100401131 in banfield_lab5::node::~node() ()
#56 0x000000010040114e in banfield_lab5::node::~node() ()
#57 0x0000000100401131 in banfield_lab5::node::~node() ()
#58 0x000000010040114e in banfield_lab5::node::~node() ()
#59 0x0000000100401131 in banfield_lab5::node::~node() ()
#60 0x000000010040114e in banfield_lab5::node::~node() ()
#61 0x0000000100401131 in banfield_lab5::node::~node() ()
#62 0x000000010040114e in banfield_lab5::node::~node() ()
#63 0x0000000100401131 in banfield_lab5::node::~node() ()
#64 0x000000010040114e in banfield_lab5::node::~node() ()
#65 0x0000000100401131 in banfield_lab5::node::~node() ()
#66 0x000000010040114e in banfield_lab5::node::~node() ()
#67 0x0000000100401131 in banfield_lab5::node::~node() ()
#68 0x000000010040114e in banfield_lab5::node::~node() ()
#69 0x0000000100401131 in banfield_lab5::node::~node() ()
#70 0x000000010040114e in banfield_lab5::node::~node() ()
#71 0x0000000100401131 in banfield_lab5::node::~node() ()
#72 0x000000010040114e in banfield_lab5::node::~node() ()
#73 0x0000000100401131 in banfield_lab5::node::~node() ()
#74 0x000000010040114e in banfield_lab5::node::~node() ()
#75 0x0000000100401131 in banfield_lab5::node::~node() ()
#76 0x000000010040114e in banfield_lab5::node::~node() ()
#77 0x0000000100401131 in banfield_lab5::node::~node() ()
#78 0x000000010040114e in banfield_lab5::node::~node() ()
#79 0x0000000100401131 in banfield_lab5::node::~node() ()
#80 0x000000010040114e in banfield_lab5::node::~node() ()
#81 0x0000000100401131 in banfield_lab5::node::~node() ()
#82 0x000000010040114e in banfield_lab5::node::~node() ()
#83 0x0000000100401131 in banfield_lab5::node::~node() ()
---Type <return> to continue, or q <return> to quit---"
It seems the problem is in the destructor for my node class:
1 2 3 4
|
node::~node(){
delete next;
delete previous;
}
|
I'm kinda sure I know what I'm doing wrong. But if anyone else knows, let me know. :)