|
|
|
|
|
|
$ gdb a.out (gdb) run foo.cpp:90:22: runtime error: member access within null pointer of type 'struct node' Program received signal SIGSEGV, Segmentation fault. 0x0000555555555c4a in BST::AddLeafPrivate (this=0x7fffffffe0a8, key=15, Ptr=0x0) at foo.cpp:90 90 else if(key < Ptr->key) //adding to left side (gdb) backtrace #0 0x0000555555555c4a in BST::AddLeafPrivate (this=0x7fffffffe0a8, key=15, Ptr=0x0) at foo.cpp:90 #1 0x0000555555555e23 in BST::AddLeafPrivate (this=0x7fffffffe0a8, key=15, Ptr=0x55555576b2e0) at foo.cpp:106 #2 0x0000555555555cea in BST::AddLeafPrivate (this=0x7fffffffe0a8, key=15, Ptr=0x55555576b2c0) at foo.cpp:94 #3 0x0000555555555cea in BST::AddLeafPrivate (this=0x7fffffffe0a8, key=15, Ptr=0x55555576b280) at foo.cpp:94 #4 0x0000555555555b6f in BST::AddLeaf (this=0x7fffffffe0a8, key=15) at foo.cpp:80 #5 0x00005555555558e7 in main () at foo.cpp:47 (gdb) up #1 0x0000555555555e23 in BST::AddLeafPrivate (this=0x7fffffffe0a8, key=15, Ptr=0x55555576b2e0) at foo.cpp:106 106 AddLeafPrivate(key, Ptr->left); (gdb) list 101 102 else if(key > Ptr->key) // adding to right side 103 { 104 if(Ptr->right != NULL) // **right** 105 { 106 AddLeafPrivate(key, Ptr->left); // **left** 107 } 108 else 109 { 110 Ptr->right = CreateLeaf(key); |
#include "BST.cpp"