My program prints out segmentation fault. It sounds like my pointer tries to access invalid address. I point out the part that may cause problem when I run gdb. Please help me analysis why it cause segmentation fault.
for(unsigned int i=0; i<myvector.size(); i++)
cout<<myvector[i]->m_number <<" ";
it starts line 35 and 36. Once I comment line 36, it passed the program. If I run line 36, it will generate segmentation fault.
Actually, I create a binary search tree structure. I stored each node in a vector.
Once I want to print out the tree, I use vector to access the element by indexing. I think this is the problem that cause segmentation fault. the type of pointer ...
actually, you can see this page. I post my whole program. http://www.cplusplus.com/forum/beginner/73233/
you can run it. it will pass the compiling but will generate seg fault finally.